Class InMemorySessionStore

java.lang.Object
dev.tachyonmcp.core.server.session.InMemorySessionStore
All Implemented Interfaces:
SessionStore, AutoCloseable

@InternalApi public class InMemorySessionStore extends Object implements SessionStore
  • Constructor Details

    • InMemorySessionStore

      public InMemorySessionStore()
  • Method Details

    • put

      public @Nullable Session put(String sessionId, Session session)
      Description copied from interface: SessionStore
      Stores a session, returning any previous session with the same ID.
      Specified by:
      put in interface SessionStore
    • get

      public Optional<Session> get(String sessionId)
      Description copied from interface: SessionStore
      Returns the session for the given ID, if present.
      Specified by:
      get in interface SessionStore
    • computeIfAbsent

      public Session computeIfAbsent(String sessionId, Function<String,Session> factory)
      Description copied from interface: SessionStore
      Returns the existing session or creates and stores a new one via the factory.
      Specified by:
      computeIfAbsent in interface SessionStore
    • values

      public Collection<Session> values()
      Description copied from interface: SessionStore
      Returns all stored sessions.
      Specified by:
      values in interface SessionStore
    • remove

      public @Nullable Session remove(String sessionId)
      Description copied from interface: SessionStore
      Removes and returns the session for the given ID.
      Specified by:
      remove in interface SessionStore
    • remove

      public boolean remove(String sessionId, Session expected)
      Description copied from interface: SessionStore
      Removes the session for the given ID only if the stored instance is expected, returning whether it was removed. Used by expiry sweeps so a replacement session created under the same ID between the expiry check and the removal is never evicted. This default is check-then-act; implementations backed by an atomic store should override it (see InMemorySessionStore).
      Specified by:
      remove in interface SessionStore
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable