Don't send expirations del events when expiration time does not change.

Expiration time is rounded up, so in case of many request per second from a
single session we can skip sending of delete event to reduce the traffic.
This is good because actually at the moment the redis repository is subscribed
for this events, even though it ignores them.

Fix gh-315
This commit is contained in:
Vladimir Tsanev
2015-11-26 14:43:31 +02:00
parent 5ca6377015
commit d85624c58e
2 changed files with 20 additions and 5 deletions

View File

@@ -68,14 +68,16 @@ final class RedisSessionExpirationPolicy {
public void onExpirationUpdated(Long originalExpirationTimeInMilli, ExpiringSession session) {
String keyToExpire = "expires:" + session.getId();
long toExpire = roundUpToNextMinute(expiresInMillis(session));
if(originalExpirationTimeInMilli != null) {
long originalRoundedUp = roundUpToNextMinute(originalExpirationTimeInMilli);
String expireKey = getExpirationKey(originalRoundedUp);
redis.boundSetOps(expireKey).remove(keyToExpire);
if(toExpire != originalRoundedUp) {
String expireKey = getExpirationKey(originalRoundedUp);
redis.boundSetOps(expireKey).remove(keyToExpire);
}
}
long toExpire = roundUpToNextMinute(expiresInMillis(session));
String expireKey = getExpirationKey(toExpire);
BoundSetOperations<Object, Object> expireOperations = redis.boundSetOps(expireKey);
expireOperations.add(keyToExpire);