Class SortedSetRedisSessionExpirationStore
java.lang.Object
org.springframework.session.data.redis.SortedSetRedisSessionExpirationStore
- All Implemented Interfaces:
RedisSessionExpirationStore
public class SortedSetRedisSessionExpirationStore
extends Object
implements RedisSessionExpirationStore
Uses a sorted set to store the expiration times for sessions. The score of each entry
is the expiration time of the session (calculated via
Session.getLastAccessedTime() + Session.getMaxInactiveInterval()). The
value is the session id. Note that cleanupExpiredSessions() only retrieves up
to 100 sessions at a time by default, use setCleanupCount(int) to increase it
if needed.- Since:
- 3.4
-
Constructor Summary
ConstructorsConstructorDescriptionSortedSetRedisSessionExpirationStore(org.springframework.data.redis.core.RedisOperations<String, Object> redisOps, String namespace) -
Method Summary
Modifier and TypeMethodDescriptionvoidRetrieves the sessions that are expected to be expired and invoketouch(String)on each of the session keys, resolved viagetSessionKey(String).voidRemove the session id from the sorted set.voidSave the session id associated with the expiration time into the sorted set.voidsetCleanupCount(int cleanupCount) Configures how many sessions will be queried at a time to be cleaned up.voidConfigure the clock used when retrieving expired sessions for clean-up.voidsetNamespace(String namespace) Set the namespace for the keys.
-
Constructor Details
-
SortedSetRedisSessionExpirationStore
-
-
Method Details
-
save
Save the session id associated with the expiration time into the sorted set.- Specified by:
savein interfaceRedisSessionExpirationStore- Parameters:
session- the session to save
-
remove
Remove the session id from the sorted set.- Specified by:
removein interfaceRedisSessionExpirationStore- Parameters:
sessionId- the session id
-
cleanupExpiredSessions
public void cleanupExpiredSessions()Retrieves the sessions that are expected to be expired and invoketouch(String)on each of the session keys, resolved viagetSessionKey(String).- Specified by:
cleanupExpiredSessionsin interfaceRedisSessionExpirationStore
-
setNamespace
Set the namespace for the keys.- Parameters:
namespace- the namespace
-
setClock
Configure the clock used when retrieving expired sessions for clean-up.- Parameters:
clock- the clock
-
setCleanupCount
public void setCleanupCount(int cleanupCount) Configures how many sessions will be queried at a time to be cleaned up. Defaults to 100.- Parameters:
cleanupCount- how many sessions to be queried, must be bigger than 0.
-