Polish RedisSession

Maintain standard using  prefix inside the RedisSession to mathods
call. Generalizing  and  methods.

Fixes gh-638
This commit is contained in:
marcoblos
2016-09-22 15:54:27 -03:00
committed by Rob Winch
parent 25aec99357
commit 4c2581d432

View File

@@ -684,7 +684,7 @@ public class RedisOperationsSessionRepository implements
this.delta.put(MAX_INACTIVE_ATTR, getMaxInactiveIntervalInSeconds());
this.delta.put(LAST_ACCESSED_ATTR, getLastAccessedTime());
this.isNew = true;
flushImmediateIfNecessary();
this.flushImmediateIfNecessary();
}
/**
@@ -705,8 +705,7 @@ public class RedisOperationsSessionRepository implements
public void setLastAccessedTime(long lastAccessedTime) {
this.cached.setLastAccessedTime(lastAccessedTime);
this.delta.put(LAST_ACCESSED_ATTR, getLastAccessedTime());
flushImmediateIfNecessary();
this.putAndFlush(LAST_ACCESSED_ATTR, getLastAccessedTime());
}
public boolean isExpired() {
@@ -731,8 +730,7 @@ public class RedisOperationsSessionRepository implements
public void setMaxInactiveIntervalInSeconds(int interval) {
this.cached.setMaxInactiveIntervalInSeconds(interval);
this.delta.put(MAX_INACTIVE_ATTR, getMaxInactiveIntervalInSeconds());
flushImmediateIfNecessary();
this.putAndFlush(MAX_INACTIVE_ATTR, getMaxInactiveIntervalInSeconds());
}
public int getMaxInactiveIntervalInSeconds() {
@@ -749,14 +747,12 @@ public class RedisOperationsSessionRepository implements
public void setAttribute(String attributeName, Object attributeValue) {
this.cached.setAttribute(attributeName, attributeValue);
this.delta.put(getSessionAttrNameKey(attributeName), attributeValue);
flushImmediateIfNecessary();
this.putAndFlush(getSessionAttrNameKey(attributeName), attributeValue);
}
public void removeAttribute(String attributeName) {
this.cached.removeAttribute(attributeName);
this.delta.put(getSessionAttrNameKey(attributeName), null);
flushImmediateIfNecessary();
this.putAndFlush(getSessionAttrNameKey(attributeName), null);
}
private void flushImmediateIfNecessary() {
@@ -765,6 +761,11 @@ public class RedisOperationsSessionRepository implements
}
}
private void putAndFlush(String a, Object v) {
this.delta.put(a, v);
this.flushImmediateIfNecessary();
}
/**
* Saves any attributes that have been changed and updates the expiration of this
* session.