Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listener for Redis in Java

Is it possible to set a listener in Redis which is triggered when an item (value/key) is inserted in Redis or when an value is changed? I researched library Jedis and Redisson, but found nothing.

like image 815
user3541830 Avatar asked Sep 29 '22 22:09

user3541830


People also ask

Can I use Redis with Java?

Redis has various Java clients you can use. However, for this tutorial, we will use Lettuce. Lettuce is a free, open-source, thread-safe Redis client that is easy to configure. It provides synchronous and asynchronous connections to Redis with minimum setup.

What is RedisMessageListenerContainer?

RedisMessageListenerContainer is a class provided by Spring Data Redis which provides asynchronous behavior for Redis message listeners. This is called internally and, according to the Spring Data Redis documentation – “handles the low level details of listening, converting and message dispatching.”

What is Redis cache in Java?

Redis is an open-source data structure store that is primarily used as a database, message broker, or cache. We can assume Redis as a No-SQL database that stores in its memory specific key-value pair kind of data thereby supporting persistent data storage as and when required.


1 Answers

Yes, you can do that with Redis' Keyspace Notifications and subscribing to the relevant channels from your Jedis/Redisson clients.

like image 142
Itamar Haber Avatar answered Oct 20 '22 11:10

Itamar Haber