A common use case when using Redis is the ability for an application to respond to changes that may occur to the value stored at a particular key or keys. Fortunately, since version 2.8, Redis provides a mechanism for client code to subscribe to a Pub/Sub channel that monitors events related to data. Called keyspace notification, functionality for monitoring events like all the commands that change a given key, all keys receiving specific commands such as
HSET, or all keys that are about to be deleted because of an
EXPIRE command. Using Redis Pub/Sub allows existing Redis clients that already implement Pub/Sub to use keyspace notification to respond to changes in the Redis data.
When a command is issued that triggers a Redis keyspace notification, two events occur that monitoring clients can respond to; the first is called a Key-space notification and the second is called a Key-event notification. In a Key-space notification event, a message is sent to a channel...