简体   繁体   English

是否可以为Redis中的所有键设置默认的ttl?

[英]Is it possible to set default ttl for all keys in redis?

I've read redis config document but can't find such option. 我已经阅读过redis config 文档,但是找不到这样的选项。

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 ! 提前致谢 !

Redis does not provide this ability - you'll have to explicitly set a TTL for every key. Redis不提供此功能-您必须为每个键显式设置一个TTL。 Note that updating a key resets its TTL, so you'll have to re-set it accordingly. 请注意,更新密钥会重置其TTL,因此您必须相应地对其进行重新设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM