From 4abfa4b37aa4f8957b7234539dee34760b505ddf Mon Sep 17 00:00:00 2001 From: Ranjith Manickam Date: Wed, 5 Dec 2018 01:56:23 +0530 Subject: [PATCH] Bug fixes and added redis sentinel supportability changes. --- .../request/session/data/cache/DataCacheConstants.java | 2 +- .../request/session/data/cache/DataCacheFactory.java | 2 +- src/main/resources/redis-data-cache.properties | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/tomcat/request/session/data/cache/DataCacheConstants.java b/src/main/java/tomcat/request/session/data/cache/DataCacheConstants.java index c5119e4..69b9936 100644 --- a/src/main/java/tomcat/request/session/data/cache/DataCacheConstants.java +++ b/src/main/java/tomcat/request/session/data/cache/DataCacheConstants.java @@ -10,7 +10,7 @@ public interface DataCacheConstants { String REDIS_HOSTS = "redis.hosts"; String REDIS_CLUSTER_ENABLED = "redis.cluster.enabled:false"; String REDIS_SENTINEL_ENABLED = "redis.sentinel.enabled:false"; - String REDIS_LB_STICKY_SESSION_ENABLED = "redis.load-balancer.sticky-session.enabled:false"; + String LB_STICKY_SESSION_ENABLED = "lb.sticky-session.enabled:false"; String REDIS_MAX_ACTIVE = "redis.max.active:10"; String REDIS_TEST_ONBORROW = "redis.test.onBorrow:true"; diff --git a/src/main/java/tomcat/request/session/data/cache/DataCacheFactory.java b/src/main/java/tomcat/request/session/data/cache/DataCacheFactory.java index b400600..ef1418a 100644 --- a/src/main/java/tomcat/request/session/data/cache/DataCacheFactory.java +++ b/src/main/java/tomcat/request/session/data/cache/DataCacheFactory.java @@ -27,7 +27,7 @@ public class DataCacheFactory { public DataCache getDataCache() { Properties properties = getApplicationProperties(); - if (Boolean.valueOf(getProperty(properties, DataCacheConstants.REDIS_LB_STICKY_SESSION_ENABLED))) { + if (Boolean.valueOf(getProperty(properties, DataCacheConstants.LB_STICKY_SESSION_ENABLED))) { return new StandardDataCache(properties, this.sessionExpiryTime); } diff --git a/src/main/resources/redis-data-cache.properties b/src/main/resources/redis-data-cache.properties index 738693c..86ed8a1 100644 --- a/src/main/resources/redis-data-cache.properties +++ b/src/main/resources/redis-data-cache.properties @@ -18,4 +18,11 @@ redis.sentinel.master=mymaster #redis.database=0 #- redis connection timeout (default value: 2000) -#redis.timeout=2000 \ No newline at end of file +#redis.timeout=2000 + +#- enable redis and standard session mode. +# If enabled, +# 1. Must be enabled sticky session in your load balancer configuration. Else this manager may not return the updated session values. +# 2. Session values are stored in local jvm and redis. +# 3. If redis is down/not responding, requests uses jvm stored session values to process user requests. Redis comes back the values will be synced. +lb.sticky-session.enabled=false