# InMemorySessionService

class InMemorySessionService : SessionService

An in-memory implementation of SessionService assuming Session objects are mutable regarding their state map, events list, and last update time.

This implementation stores sessions, user state, and app state directly in memory in a thread-safe manner. It is suitable for testing or single-node deployments where persistence is not required.

Note: State merging (app/user state prefixed with `app:` / `user:`) occurs during retrieval operations (getSession, createSession).

## Constructors

InMemorySessionService
Link copied to clipboard
constructor()

## Functions

appendEvent
Link copied to clipboard
open suspend override fun appendEvent(session: Session, event: Event): Event

Appends an event to an in-memory session object and updates the session's state based on the event's state delta, if applicable.

closeSession
Link copied to clipboard
open suspend fun closeSession(session: Session)

Closes a session.

createSession
Link copied to clipboard
open suspend override fun createSession(key: SessionKey, state: Map<String, Any>?): Session

Creates a new session with the specified parameters.

deleteSession
Link copied to clipboard
open suspend override fun deleteSession(key: SessionKey)

Deletes a specific session.

getSession
Link copied to clipboard
open suspend override fun getSession(key: SessionKey, config: GetSessionConfig?): Session?

Retrieves a specific session, optionally filtering the events included.

listEvents
Link copied to clipboard
open suspend override fun listEvents(key: SessionKey): ListEventsResponse

Lists the events within a specific session.

listSessions
Link copied to clipboard
open suspend override fun listSessions(appName: String, userId: String): ListSessionsResponse

Lists sessions associated with a specific application and user.