@Singleton
public class SessionCache
extends java.lang.Object
Constructor and Description |
---|
SessionCache() |
Modifier and Type | Method and Description |
---|---|
java.util.Optional<Session> |
cacheSession(java.util.UUID playerUUID,
Session session)
Cache a new session.
|
static void |
clear() |
java.util.Optional<Session> |
endSession(java.util.UUID playerUUID,
long time)
End a session and save it to database.
|
static java.util.Map<java.util.UUID,Session> |
getActiveSessions() |
static java.util.Optional<Session> |
getCachedSession(java.util.UUID playerUUID)
Used to get the Session of the player in the sessionCache.
|
static void |
refreshActiveSessionsState() |
protected void |
removeSessionFromCache(java.util.UUID playerUUID) |
public static java.util.Map<java.util.UUID,Session> getActiveSessions()
public static void clear()
public static void refreshActiveSessionsState()
public static java.util.Optional<Session> getCachedSession(java.util.UUID playerUUID)
playerUUID
- UUID of the player.public java.util.Optional<Session> cacheSession(java.util.UUID playerUUID, Session session)
playerUUID
- UUID of the playersession
- Session to cache.public java.util.Optional<Session> endSession(java.util.UUID playerUUID, long time)
playerUUID
- UUID of the player.time
- Time the session ended.protected void removeSessionFromCache(java.util.UUID playerUUID)