title: redis pub sub only for a certain set of keys?
body: <p>I have a use case in which I want to enable notification only for a certain set of keys, so that when those keys expire I can get a notification from redis.</p>
  
  <p>I have followed <a href="https://stackoverflow.com/questions/26406303/redis-key-expire-notification-with-jedis">this</a> answer to implement this.</p>
  
  <p>I have set parameter notify-keyspace-events to "Ex"</p>
  
  <p>To accomplish this I am adding keys that I want notification for in DB-0 and the other keys in DB-1. But I am recieveing notification for both the DBs. Is there any way to just get notification from a particular DB?</p>
  
  <p>According to redis  documentation :</p>
  
  <p>"<em>Redis can notify Pub/Sub clients about events happening in the key space.
  This feature is documented at <a href="http://redis.io/topics/notifications" rel="nofollow noreferrer">http://redis.io/topics/notifications</a>
  For instance if keyspace events notification is enabled, and a client
  performs a DEL operation on key "foo" stored in the <strong>Database 0</strong>, two
  messages will be published via Pub/Sub:</em></p>
  
  <p>PUBLISH <strong>keyspace@0</strong>:foo del</p>
  
  <p>PUBLISH <strong>keyevent@0</strong>:del foo
  "</p>
  
  <p>But I am receiving notification from both DB-0 and DB-1.</p>
  
  <p>PS : I know I can filter keys in my application, but I store too many expiring keys in redis and sending notification for all the expiring will increase load on my redis server.</p>