Class InMemorySessionEventStore

java.lang.Object
dev.tachyonmcp.core.server.session.InMemorySessionEventStore
All Implemented Interfaces:
SessionEventStore, Closeable, AutoCloseable

@InternalApi public final class InMemorySessionEventStore extends Object implements SessionEventStore
In-memory event log bounded to maxEvents: appends past the cap drop the oldest entry (they remain unrecoverable — an SSE client reconnecting with a Last-Event-ID older than the window simply misses those events, matching typical broker retention semantics).

Cursors handed out by drain(java.lang.String, long, java.util.function.Predicate<dev.tachyonmcp.core.server.session.SessionEvent>) are global append indices, stable across trims via the firstIndex offset. Reads snapshot the window under the lock and process outside it, so a slow consumer never blocks appends.

Guarded by a ReentrantLock, not synchronized: appends run on virtual threads, and on Java 21 a VT contending on a monitor pins its carrier thread (fixed only in JEP 491 / Java 24). A j.u.c lock parks the virtual thread instead and frees the carrier.

  • Constructor Details

    • InMemorySessionEventStore

      public InMemorySessionEventStore()
    • InMemorySessionEventStore

      public InMemorySessionEventStore(long firstIndex, int maxEvents)
  • Method Details