提交 959fad17 编写于 作者: N Nikita Koksharov

Fixed - Tomcat Session expires in Redis earlier than scheduled by Tomcat. #1861

上级 4fbaa1bf
......@@ -117,9 +117,13 @@ public class RedissonSession extends StandardSession {
if (readMode == ReadMode.MEMORY) {
topic.publish(createPutAllMessage(newMap));
}
if (getMaxInactiveInterval() >= 0) {
map.expire(getMaxInactiveInterval(), TimeUnit.SECONDS);
}
expireSession();
}
}
protected void expireSession() {
if (maxInactiveInterval >= 0) {
map.expire(maxInactiveInterval + 60, TimeUnit.SECONDS);
}
}
......@@ -137,9 +141,7 @@ public class RedissonSession extends StandardSession {
if (map != null) {
fastPut(MAX_INACTIVE_INTERVAL_ATTR, maxInactiveInterval);
if (maxInactiveInterval >= 0) {
map.expire(getMaxInactiveInterval(), TimeUnit.SECONDS);
}
expireSession();
}
}
......@@ -235,9 +237,7 @@ public class RedissonSession extends StandardSession {
topic.publish(createPutAllMessage(newMap));
}
if (maxInactiveInterval >= 0) {
map.expire(getMaxInactiveInterval(), TimeUnit.SECONDS);
}
expireSession();
}
public void load(Map<String, Object> attrs) {
......
......@@ -117,9 +117,13 @@ public class RedissonSession extends StandardSession {
if (readMode == ReadMode.MEMORY) {
topic.publish(createPutAllMessage(newMap));
}
if (getMaxInactiveInterval() >= 0) {
map.expire(getMaxInactiveInterval(), TimeUnit.SECONDS);
}
expireSession();
}
}
protected void expireSession() {
if (maxInactiveInterval >= 0) {
map.expire(maxInactiveInterval + 60, TimeUnit.SECONDS);
}
}
......@@ -137,9 +141,7 @@ public class RedissonSession extends StandardSession {
if (map != null) {
fastPut(MAX_INACTIVE_INTERVAL_ATTR, maxInactiveInterval);
if (maxInactiveInterval >= 0) {
map.expire(getMaxInactiveInterval(), TimeUnit.SECONDS);
}
expireSession();
}
}
......@@ -235,9 +237,7 @@ public class RedissonSession extends StandardSession {
topic.publish(createPutAllMessage(newMap));
}
if (maxInactiveInterval >= 0) {
map.expire(getMaxInactiveInterval(), TimeUnit.SECONDS);
}
expireSession();
}
public void load(Map<String, Object> attrs) {
......
......@@ -117,12 +117,16 @@ public class RedissonSession extends StandardSession {
if (readMode == ReadMode.MEMORY) {
topic.publish(createPutAllMessage(newMap));
}
if (getMaxInactiveInterval() >= 0) {
map.expire(getMaxInactiveInterval(), TimeUnit.SECONDS);
}
expireSession();
}
}
protected void expireSession() {
if (maxInactiveInterval >= 0) {
map.expire(maxInactiveInterval + 60, TimeUnit.SECONDS);
}
}
protected AttributesPutAllMessage createPutAllMessage(Map<String, Object> newMap) {
Map<String, Object> map = new HashMap<String, Object>();
for (Entry<String, Object> entry : newMap.entrySet()) {
......@@ -137,9 +141,7 @@ public class RedissonSession extends StandardSession {
if (map != null) {
fastPut(MAX_INACTIVE_INTERVAL_ATTR, maxInactiveInterval);
if (maxInactiveInterval >= 0) {
map.expire(getMaxInactiveInterval(), TimeUnit.SECONDS);
}
expireSession();
}
}
......@@ -235,9 +237,7 @@ public class RedissonSession extends StandardSession {
topic.publish(createPutAllMessage(newMap));
}
if (maxInactiveInterval >= 0) {
map.expire(getMaxInactiveInterval(), TimeUnit.SECONDS);
}
expireSession();
}
public void load(Map<String, Object> attrs) {
......
......@@ -117,12 +117,16 @@ public class RedissonSession extends StandardSession {
if (readMode == ReadMode.MEMORY) {
topic.publish(createPutAllMessage(newMap));
}
if (getMaxInactiveInterval() >= 0) {
map.expire(getMaxInactiveInterval(), TimeUnit.SECONDS);
}
expireSession();
}
}
protected void expireSession() {
if (maxInactiveInterval >= 0) {
map.expire(maxInactiveInterval + 60, TimeUnit.SECONDS);
}
}
protected AttributesPutAllMessage createPutAllMessage(Map<String, Object> newMap) {
Map<String, Object> map = new HashMap<String, Object>();
for (Entry<String, Object> entry : newMap.entrySet()) {
......@@ -137,9 +141,7 @@ public class RedissonSession extends StandardSession {
if (map != null) {
fastPut(MAX_INACTIVE_INTERVAL_ATTR, maxInactiveInterval);
if (maxInactiveInterval >= 0) {
map.expire(getMaxInactiveInterval(), TimeUnit.SECONDS);
}
expireSession();
}
}
......@@ -234,10 +236,7 @@ public class RedissonSession extends StandardSession {
if (readMode == ReadMode.MEMORY) {
topic.publish(createPutAllMessage(newMap));
}
if (maxInactiveInterval >= 0) {
map.expire(getMaxInactiveInterval(), TimeUnit.SECONDS);
}
expireSession();
}
public void load(Map<String, Object> attrs) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册