参考:https://www.jianshu.com/p/ecf6b458194c
https://www.cnblogs.com/tangxuliang/p/10659439.html#3091253873
Redis事件通知(keyspace notification)
Keyspace 通知使得客户端可以通过订阅频道或模式,来接收那些以某种方式改动了 Redis 数据集的事件(触发某些事件后可以向指定的频道发送通知),该功能需要 Redis 版本大于 2.8。
事件通过 Redis 的订阅与发布功能(pub/sub)来进行分发,因此所有支持订阅与发布功能的客户端都可以在无须做任何修改的情况下,直接使用此功能。
事件的类型#
对于每个修改数据库的操作,键空间通知都会发送两种不同类型的事件:键空间通知(key-space)和键事件通知(key-event)。
当 del mykey 命令执行时:
- 键空间频道的订阅者将接收到被执行的事件的名字,在这个例子中,就是 del
- 键事件频道的订阅者将接收到被执行事件的键的名字,在这个例子中,就是 mykey
K Keyspace events, published with __keyspace@<db>__ prefix.
E Keyevent events, published with __keyevent@<db>__ prefix.
g Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ...
$ String commands
l List commands
s Set commands
h Hash commands
z Sorted set commands
x Expired events (events generated every time a key expires)
e Evicted events (events generated when a key is evicted for maxmemory)
A Alias for g$lshzxe, so that the "AKE" string means all the events.

665

被折叠的 条评论
为什么被折叠?



