From 6fb7e3dfda24ad247bf70ea063356aa1226f661b Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Thu, 26 Jun 2014 16:52:19 -0500 Subject: [PATCH] Add defaultMaxInactiveInterval to REdisOperationsSessionRepository --- .../RedisOperationsSessionRepository.java | 20 ++++++++- ...RedisOperationsSessionRepositoryTests.java | 41 +++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 src/test/java/org/springframework/session/redis/RedisOperationsSessionRepositoryTests.java diff --git a/src/main/java/org/springframework/session/redis/RedisOperationsSessionRepository.java b/src/main/java/org/springframework/session/redis/RedisOperationsSessionRepository.java index 5957e035..05d09386 100644 --- a/src/main/java/org/springframework/session/redis/RedisOperationsSessionRepository.java +++ b/src/main/java/org/springframework/session/redis/RedisOperationsSessionRepository.java @@ -39,11 +39,23 @@ public class RedisOperationsSessionRepository implements SessionRepository redisTemplate; + private Integer defaultMaxInactiveInterval; + public RedisOperationsSessionRepository(RedisOperations redisTemplate) { this.redisTemplate = redisTemplate; } - @Override + /** + * Sets the maximum inactive interval in seconds between requests before newly created sessions will be + * invalidated. A negative time indicates that the session will never timeout. + * + * @param defaultMaxInactiveInterval the number of seconds that the {@link Session} should be kept alive between client requests. + */ + public void setDefaultMaxInactiveInterval(int defaultMaxInactiveInterval) { + this.defaultMaxInactiveInterval = defaultMaxInactiveInterval; + } + + @Override public void save(RedisSession session) { session.saveDelta(); } @@ -79,7 +91,11 @@ public class RedisOperationsSessionRepository implements SessionRepository