Class SessionCache
- java.lang.Object
-
- com.djrapitops.plan.gathering.cache.SessionCache
-
@Singleton public class SessionCache extends java.lang.Object
This class is used to store active sessions of players in memory.
-
-
Constructor Summary
Constructors Constructor Description SessionCache()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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()
-
-
-
Method Detail
-
getActiveSessions
public static java.util.Map<java.util.UUID,Session> getActiveSessions()
-
clear
public static void clear()
-
refreshActiveSessionsState
public static void refreshActiveSessionsState()
-
getCachedSession
public static java.util.Optional<Session> getCachedSession(java.util.UUID playerUUID)
Used to get the Session of the player in the sessionCache.- Parameters:
playerUUID
- UUID of the player.- Returns:
- Optional with the session inside it if found.
-
cacheSession
public java.util.Optional<Session> cacheSession(java.util.UUID playerUUID, Session session)
Cache a new session.- Parameters:
playerUUID
- UUID of the playersession
- Session to cache.- Returns:
- Optional: previous session. Recipients of this object should decide if it needs to be saved.
-
endSession
public java.util.Optional<Session> endSession(java.util.UUID playerUUID, long time)
End a session and save it to database.- Parameters:
playerUUID
- UUID of the player.time
- Time the session ended.- Returns:
- Optional: ended session. Recipients of this object should decide if it needs to be saved.
-
-