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 

 

posted @ 2020-01-21 14:11  BloggerSb  阅读(2363)  评论(0编辑  收藏  举报