Listener for Redis in Java

Is it possible to set a listener in Redis that is triggered when an item (value / key) is inserted into Redis or when a value is changed? I researched the Jedis and Radisson library but couldn't find anything.

+3


source to share


2 answers


Yes, you can do this with Redis' Key Notifications and subscribe to the appropriate channels from your Jedis / Redisson clients.



+6


source


There is no feature in Redis to support this. The client will simply need to request data over and over again to get the information so that the notification you are looking for can be made.

I assume you have to use the Redis pipe function (then you need to make changes in the client that actually push the data into your redis database)

Where do you subscribe SUBSCRIBE hashtablekeychannel



Those. data insert must be changed to HSET hashtablekey key "value" PUBLISH hashtablekeychannel key

(Actually, in most cases, you could just drop the hashtable and post its value, but that's another story too)

-2


source







All Articles