赞
踩
今天查看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的值则不会改变有效时间。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。