确认Redis中lpush和expire的使用情况

从Redis 2.1.3之前的版本开始,如果在lpush操作中添加了expire,那么似乎在执行lpush时该数据将被删除。但在当前版本中,数据不会被删除,这是对其行为进行的确认备忘录。设置了3秒的expire后,即使进行了lpush操作,数据也不会被删除,只有在3秒后才会因为过期而被删除。

[vagrant@localhost ~]$ redis-cli lpush mylist hello hoge
(integer) 2
[vagrant@localhost ~]$ redis-cli expire mylist 3
(integer) 1
[vagrant@localhost ~]$ redis-cli lpush mylist hello hoge
(integer) 4
[vagrant@localhost ~]$ redis-cli lpush mylist hello hoge
(integer) 6
[vagrant@localhost ~]$ redis-cli lpush mylist hello hoge
(integer) 8
[vagrant@localhost ~]$ redis-cli lpush mylist hello hoge
(integer) 10
[vagrant@localhost ~]$ redis-cli lpush mylist hello hoge
(integer) 2
广告
将在 10 秒后关闭
bannerAds