当前位置:   article > 正文

redis set设置有效时间问题_redis set 时间

redis set 时间

今天查看redis数据库数据的,无意中发现一条本应该删掉的set数据还一直存在,以为是代码的bug没有给数据设置有效值,结果重新啃了半天的代码,发现都在初始化的时候设置了有效值,经过多次试验发现,set结构的数据在更新数据的时候,会重置有效期,于是去官网上看了下:

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的有效时间,但是类似于incr、lpush、hset等概念上更改key的值则不会改变有效时间。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/466886
推荐阅读
相关标签
  

闽ICP备14008679号