node.js 使用redis做监听过期事件遇到的问题
发布于 6 年前 作者 Carl-piao 3478 次浏览 来自 问答

设置的key过期以后用redis.psubscribe()是可以监听到过期的key,问题是会重复的监听到相同的key,怎么才能不重复呢 图片.png 如这图片的显示来说,我用set(key, value, 10, “EX”, redis.print)做了个过期处理,连续的向这个key提交了几次,然后等待过期。按照redis逻辑来说,该key过期只会监听到一次就够了,但是重复了

2 回复

Tells Redis to delete the key after ttl seconds. If we are using Redis < 2.1.3 and if a ttl was already set with another prior client.expire invocation, then the new ttl does NOT override the old ttl. If we are using Redis >= 2.1.3 and if a ttl was already set with another prior client.expire invocation, then the new ttl DOES override the old ttl. The expiry can be removed from the key if the key is set to a new value using the client.set(key, value) command or when a key is destroyed via the client.del(key) command. Passes 1 to callback if key has no current ttl expiry. Passes 0 to callback if key does not exist or if we are using Redis < 2.1.3, and key already has a current ttl expiry. 升级就好了

不是很明白这句话的意思,至于升级是升级redis的版本吗,redis的版本是比较新的版本

回到顶部