Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

Make Redis as optional

$
0
0

I am using spring boot with Redis.Redis is running as Docker container

spring.cache.type=redisspring.redis.host=localhostspring.redis.port=6379 

Redis is a memory DB, if it finds data in Redis based on the key, it retrieved from Redis otherwise go into actual db call.when Redis is running, code works fine. but sometimes for any reason, if Redis is down, I am getting exception RedisConnectionException: Unable to connect to localhost:6379

I want to make it optional. if it gets down, code should work as it is, by calling actual DB data(sql service repositories).

is there any way to make Redis call as optional.

if running, work with Redis, if down, can to actual DB without exception.

my code

@Cacheable(cacheNames = CACHE_USER_DETAILS)    public User getUserDetails(String username) {      //call data from sql serever via repositories.}

Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>