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

我是研究僧i 提交于 2021-02-13 22:43:46

设置成功返回 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 

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!