Skip to content

Instantly share code, notes, and snippets.

@odedia
Created December 5, 2017 14:46
Show Gist options
  • Select an option

  • Save odedia/573241f11b1cf63c45f0dca69cfc0318 to your computer and use it in GitHub Desktop.

Select an option

Save odedia/573241f11b1cf63c45f0dca69cfc0318 to your computer and use it in GitHub Desktop.
public void cleanExpiredSessions() {
long now = System.currentTimeMillis();
long prevMin = roundDownMinute(now);
if (logger.isDebugEnabled()) {
logger.debug("Cleaning up sessions expiring at " + new Date(prevMin));
}
String expirationKey = getExpirationKey(prevMin);
Set<Object> sessionsToExpire = this.redis.boundSetOps(expirationKey).members();
this.redis.delete(expirationKey);
for (Object session : sessionsToExpire) {
String sessionKey = getSessionKey((String) session);
touch(sessionKey);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment