3

I've read redis config document but can't find such option.

I've searched and found that "by default, the key will simply live forever". And I want to change this default behavior eagerly.

Normally Redis keys are created without an associated time to live. The key will simply live forever, unless it is removed by the user in an explicit way, for instance using the DEL command. 
The EXPIRE family of commands is able to associate an expire to a given key, at the cost of some additional memory used by the key. When a key has an expire set, Redis will make sure to remove the key when the specified amount of time elapsed.

http://redis.io/commands/expire (again)

Thanks in advance !

4

1 回答 1

6

Redis 不提供此功能 - 您必须为每个键显式设置 TTL。请注意,更新密钥会重置其 TTL,因此您必须相应地重新设置它。

于 2015-08-10T05:17:44.320 回答