Class InMemorySessionStore
java.lang.Object
com.svenruppert.jsentinel.session.InMemorySessionStore
- All Implemented Interfaces:
SessionStore
@ExperimentalJSentinelApi
public final class InMemorySessionStore
extends Object
implements SessionStore
In-memory
SessionStore backed by a
LinkedHashMap so findBySubject(TenantId, SubjectId)
returns insertion-ordered results.
Thread-safety: a ReentrantReadWriteLock serialises writes
and lets queries proceed in parallel.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanRemoves the record forsessionId.findAll()Returns every record currently persisted, in insertion order.Looks up the record for a session id.findBySubject(TenantId tenant, SubjectId subjectId) Returns every record (in anySessionStatus) belonging tosubjectIdwithintenant, in insertion order (oldest first).voidsave(SessionRecord session) Persists or replaces the supplied session record.
-
Constructor Details
-
InMemorySessionStore
public InMemorySessionStore()Creates an empty store.
-
-
Method Details
-
save
Description copied from interface:SessionStorePersists or replaces the supplied session record. Keyed onSessionRecord.sessionId().- Specified by:
savein interfaceSessionStore- Parameters:
session- record to persist; must not benull
-
findById
Description copied from interface:SessionStoreLooks up the record for a session id.- Specified by:
findByIdin interfaceSessionStore- Parameters:
sessionId- session identifier; must not benull- Returns:
- the record, if present
-
findBySubject
Description copied from interface:SessionStoreReturns every record (in anySessionStatus) belonging tosubjectIdwithintenant, in insertion order (oldest first).- Specified by:
findBySubjectin interfaceSessionStore- Parameters:
tenant- tenant scope; must not benullsubjectId- subject; must not benull- Returns:
- immutable list of records; empty when none exist
-
delete
Description copied from interface:SessionStoreRemoves the record forsessionId.- Specified by:
deletein interfaceSessionStore- Parameters:
sessionId- session identifier; must not benull- Returns:
trueif a record was removed,falsewhen no such session existed
-
findAll
Description copied from interface:SessionStoreReturns every record currently persisted, in insertion order. Used by admin tooling — e.g. the Phase-8aSessionManagementView— that needs the full session inventory across all subjects.Default returns an empty list so pre-existing implementations keep compiling; concrete stores override.
- Specified by:
findAllin interfaceSessionStore- Returns:
- immutable list of records, possibly empty; never
null
-