Redis设置和更新Key的过期时间


设置成功返回 1 。

当 key 不存在或者不能为 key 设置生存时间时(比如在低于 2.1.3 版本的 Redis 中你尝试更新 key 的生存时间),返回 0 。

redis> SET cache_page "www.google.com"
OK
 
redis> EXPIRE cache_page 30  # 设置过期时间为 30 秒
(integer) 1
 
redis> TTL cache_page    # 查看剩余生存时间
(integer) 23
 
redis> EXPIRE cache_page 30000   # 更新过期时间
(integer) 1
 
redis> TTL cache_page
(integer) 29996
 

 

源文:https://blog.csdn.net/u012045045/article/details/82901876 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM