Interface SessionStore

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
InMemorySessionStore

public interface SessionStore extends AutoCloseable
Storage abstraction for MCP sessions.
  • Method Details

    • put

      @Nullable Session put(String sessionId, Session session)
      Stores a session, returning any previous session with the same ID.
    • get

      Optional<Session> get(String sessionId)
      Returns the session for the given ID, if present.
    • computeIfAbsent

      Session computeIfAbsent(String sessionId, Function<String,Session> factory)
      Returns the existing session or creates and stores a new one via the factory.
    • values

      Collection<Session> values()
      Returns all stored sessions.
    • remove

      @Nullable Session remove(String sessionId)
      Removes and returns the session for the given ID.
    • remove

      default boolean remove(String sessionId, Session expected)
      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).