The keyspace notifications have been essential for a recent web api I\'ve been developing.
We have redis setup in azure. The api mostly works, we use notifications t
Just as the other answer mentioned, there's no such notification.
After all, Keyspace Notification is a notification for events on a single key. Each notification is associated with a key. For keyspace
event, the key name is part of the channel name. For keyevent
event, the key name is the message.
PUBLISH __keyspace@0__:key_name comamnd
PUBLISH __keyevent@0__:command key_name
Each command that sending a notification must have a key as argument. e.g. del key
, set key val
. However, the flushdb
command has no key as argument. The command doesn't affect a single key. Instead, it removes all keys in the database. So there's no such notification for it. Otherwise, what do you expect from the channel? All keys that have been removed? It's not a good idea.
However, you can simulate an event for flushdb
flushdb-event
: set flushdb-event 0
subscribe __keyspace@0__:flushdb-event
flushdb
: set flushdb-event 1
In this way, you can get the simulated flushdb
notification.