Search code examples
javaredispublish-subscribejedis

Jedis Pub/Sub Value of Key


Is there any way to multicast the value of a changed key with Jedis pub/sub?

I'm currently running:

jedis.psubscribe(new MyListener(), "__key*__:*");

And I get messages such as:

onPMessage pattern __key*__:* __keyspace@0__:testTag0 set
onPMessage pattern __key*__:* __keyevent@0__:set testTag0
onPMessage pattern __key*__:* __keyspace@0__:testTag0 del
onPMessage pattern __key*__:* __keyevent@0__:del testTag0

I would also like to get a message over Jedis pub/sub with the value of the key that was set. For example, something like:

onPMessage pattern __key*__:* __keyevent@0__:set testTag0 tagValue

Solution

  • While this is a somewhat common need, keyspace notifications do not include the actual values, hence what you're looking for isn't possible.