Package overit.geocall.rs
Class MicroSessionCacheService
java.lang.Object
overit.geocall.rs.MicroSessionCacheService
MicroSessionCacheService is a class that provides a cache for MicroSession objects. It uses an ExpiringMap to store the
MicroSession objects with an expiration time. The cache allows retrieval, insertion, and removal of MicroSessions.
MicroSessionCacheService is a singleton class, meaning there is only one instance of it throughout the application.
It can be accessed using the getInstance() method. The MicroSessionCacheService instance holds the ExpiringMap
cache and a Clock object to manage expiration logic.
Expiration of MicroSessions is handled through the ExpiringMap. It periodically removes expired MicroSessions using a background cleaning process executed by a scheduled executor service.
Usage:
// Retrieve the MicroSessionCacheService instance
MicroSessionCacheService sessionCache = MicroSessionCacheService.getInstance();
// Get a MicroSession from the cache
MicroSession session = sessionCache.get("sessionId");
// Put a MicroSession into the cache
sessionCache.put(session);
// Remove a MicroSession from the cache
sessionCache.remove(session);
-
Method Summary
Modifier and TypeMethodDescriptionRetrieves a MicroSession from the cache using the given session ID.static MicroSessionCacheServicegetInstance retrieves the singleton instance of MicroSessionCacheService.voidput(MicroSession microSession) Stores a MicroSession in the cache with an expiration time based on the session latency of the associated Identity.voidput(MicroSession microSession, long expiration) Stores a MicroSession in the cache with an expiration time.voidRemoves the MicroSession from the cache.
-
Method Details
-
getInstance
getInstance retrieves the singleton instance of MicroSessionCacheService.- Returns:
- the singleton instance of MicroSessionCacheService
-
get
Retrieves a MicroSession from the cache using the given session ID.- Parameters:
sessionId- the session ID used to retrieve the MicroSession- Returns:
- the MicroSession associated with the session ID, or null if no mapping is found
-
put
Stores a MicroSession in the cache with an expiration time based on the session latency of the associated Identity.- Parameters:
microSession- the MicroSession to be stored in the cache
-
put
Stores a MicroSession in the cache with an expiration time.- Parameters:
microSession- the MicroSession to be stored in the cacheexpiration- the expiration of the cache in ms
-
remove
Removes the MicroSession from the cache.- Parameters:
microSessionId- the MicroSession identifier to be removed from the cache
-