Can the time live (TTL) for a memcached key be set to infinite?

I have implemented memcache in my PHP-MySQL based application and it is regularly updated from the backend process.
Because of this, some data contradicts the expiration time and other processes, so I came up with a solution, but for this I would have to make TTL = infinite.

Can anyone help me achieve this?

+8
php memcached
source share
3 answers

Easy - just write 0.

expire

The validity period of an item. If it is zero, the item will never expire . You can also use a Unix timestamp or number of seconds starting from the current time, but in the latter case, the number of seconds can be no more than 2592000 (30 days).

+14
source share

You can set the TTL to 0, which means it should never expire.

But remember that it will never be infinite. The data is stored in memory and will be lost in some circumstances, the most obvious of which is a server reboot. :)

You should always be able to recover this data when memcache fails.

More information can be found here .

+4
source share

As far as I know, if you do not install ttl, it will never expire.

However, there are policy replacements for keys, which you can read about here.

0
source share

All Articles