I am using redis as a cache in one of my spring boot java application. I am performing only get operation on this redis instance from a scheduler code which runs every 30 seconds and write operation is performed by some other application. I have a scenario where if my redis instance goes down due to any reason then I have to stop doing a particular action. I am using jedis as redis client.
Assume my jedis pool was configured and connection pool was created successfully.
For couple of iterations my scheduler worked fine and was able to perform the get operation on redis.
Now assume redis went down so now at this point after 30 seconds my scheduler will run again and it will fail to perform get operation.
I just need to identify if redis went down at this point.
Is there any way to identify if the redis went down in above mentioned scenario?
2
Answers
It took me sometime to figure out as I am new to redis but I found a simple way by catching the JedisConnectionException as this exception is thrown when redis server is down. Posting the answer if someone might face this scenario.
Connect to redis server via Jedis client and run info command to get more information: