我想知道redis中是否有一个功能可以让我获得所有过期的键(我的意思是某种事件,它让我有机会收回所有过期记录)。它的目的是将旧值保存到另一个数据库中。我听说可以使用发布机制,但谷歌无法帮助我们实现这个想法。
最佳答案
redis 的当前开发版本包含一个新功能:键空间通知。文档:http://redis.io/topics/notifications
Keyspace notifications allows clients to subscribe to Pub/Sub channels in order to receive events affecting the Redis data set in some way.
Examples of the events that is possible to receive are the following:
- All the commands affecting a given key.
- All the keys receiving an LPUSH operation.
- All the keys expiring in the database 0.
希望它能尽快稳定下来。
顺便说一句,它在帮助您保存过期 key 的值方面不是很有用。当触发过期事件时,该值已经消失。
关于redis - key 过期事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14647494/