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 Details

    • InMemorySessionStore

      public InMemorySessionStore()
      Creates an empty store.
  • Method Details

    • save

      public void save(SessionRecord session)
      Description copied from interface: SessionStore
      Persists or replaces the supplied session record. Keyed on SessionRecord.sessionId().
      Specified by:
      save in interface SessionStore
      Parameters:
      session - record to persist; must not be null
    • findById

      public Optional<SessionRecord> findById(SessionId sessionId)
      Description copied from interface: SessionStore
      Looks up the record for a session id.
      Specified by:
      findById in interface SessionStore
      Parameters:
      sessionId - session identifier; must not be null
      Returns:
      the record, if present
    • findBySubject

      public List<SessionRecord> findBySubject(TenantId tenant, SubjectId subjectId)
      Description copied from interface: SessionStore
      Returns every record (in any SessionStatus) belonging to subjectId within tenant, in insertion order (oldest first).
      Specified by:
      findBySubject in interface SessionStore
      Parameters:
      tenant - tenant scope; must not be null
      subjectId - subject; must not be null
      Returns:
      immutable list of records; empty when none exist
    • delete

      public boolean delete(SessionId sessionId)
      Description copied from interface: SessionStore
      Removes the record for sessionId.
      Specified by:
      delete in interface SessionStore
      Parameters:
      sessionId - session identifier; must not be null
      Returns:
      true if a record was removed, false when no such session existed
    • findAll

      public List<SessionRecord> findAll()
      Description copied from interface: SessionStore
      Returns every record currently persisted, in insertion order. Used by admin tooling — e.g. the Phase-8a SessionManagementView — 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:
      findAll in interface SessionStore
      Returns:
      immutable list of records, possibly empty; never null