redis subscribe to key
Redis has a buildin pubsub mechanism, but by default it is not possible to listen on specific keys. Redis 2.8 intruduced Keyspace Notifications , to which you can subscribe.
First of all. This feature is disabled by default, so we need to enable it
$ redis-cli config set notify-keyspace-events KAE
This little python-script listens on keyspace-Events containing stash:silence/*
#!/usr/bin/env python
import redis
r = redis.StrictRedis()
pubsub = r.pubsub()
pubsub.psubscribe('__keyspace@*:stash:silence/*')
for msg in pubsub.listen():
print(msg)
Results to: