Spring session in Redis - what is the transition to another resource when Redis is disabled

I use Spring and Spring Security and want to use spring-session-data-redis with RedisHttpSessionConfiguration to enable saving session identifiers in redis (so that clients do not lose their sessions when the web server is down and switches to another server).

My question is, what happens when the Redis server is down? Will Spring continue to work, keeping the session in memory until Redis returns? Is there any way to configure this like this?

I am using Redis on AWS ElastiCache, and Failover may take several minutes before replacing the primary node with DNS.

+6
source share
1 answer

As far as I can see, you will need to provide an implementation of CacheErrorHandler ( javadoc ).

You can do this by providing a Configuration instance that implements CachingConfigurer and overriding the errorHandler() method.

For instance:

 @Configuration @Ena1bleCaching public class MyApp extends SpringBootServletInitializer implements CachingConfigurer { @Override public CacheErrorHandler errorHandler() { return MyAppCacheErrorHandler(); } } 

It’s not clear to HOW you provide a continuous service — without duplicating current sessions in the rollback cache, this seems impossible.

If you use ElasticCache, is it not possible for AWS to handle the replicated configuration for you, so if one node goes, the other can take over?

0
source

All Articles