redis set 超时_Redis 更新(set) key值过期时间被重置
Redis 更新(set) key值過期時間被重置的問題:
問題描述:
當你在redis中插入一個key值,并且設置了對應過期時間.,當過期時間還沒到的時候重新更新 key 值會導致過期時間被刷新。
針對這個問題 redis的官方文檔是這么解釋的:
The timeout will only be cleared by commands that delete or overwrite the contents of the key, including DEL, SET, GETSET and all the *STORE commands. This means that all the operations that conceptually alter the value stored at the key without replacing it with a new one will leave the timeout untouched. For instance, incrementing the value of a key with INCR, pushing a new value into a list with LPUSH, or altering the field value of a hash with HSET are all operations that will leave the timeout untouched.
大致意思:
如果用DEL, SET, GETSET會將key對應存儲的值替換成新的,命令也會清除掉超時時間;如果 list 結構中添加一個數據或者改變hset數據的一個字段是不會清除超時時間的;如果想要通過set去覆蓋值那就必須重新設置expire。
歡迎分享,(木莊網絡博客交流QQ群:562366239)
總結
以上是生活随笔為你收集整理的redis set 超时_Redis 更新(set) key值过期时间被重置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python数据库操作批量sql执行_使
- 下一篇: mysql内连接简写_技术分享 | My