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

Easy - just write 0 there.

expire

Expiration time of the item. If it's equal to zero, the item will never expire. You can also use Unix timestamp or a number of seconds starting from current time, but in the latter case the number of seconds may not exceed 2592000 (30 days).


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

But remember that it will never really be infinite. The data is stored in memory and will be lost under some circumstances, the most obvious being the server being rebooted. :)

You should always have the possibility to reconstruct that data when the memcache fails.

More details to be found here.

Tags:

Php

Memcached