class MemorySessionStore
implements ISessionStore
Since 0.2.0

Map-backed ISessionStore.

Examples

Example 1

SessionPlugin({ secret, store: 'memory' });

Constructors

MemorySessionStore(deps: MemorySessionStoreDeps)
Parameters

Injected clock and timer functions

Properties

readonly
size: number

How many entries are currently held, expired ones included.

Methods

close(): Promise<void>

Releases resources held by the store (timers, connections).

Optional: called from the plugin's onClose. A store holding nothing omits it.

destroy(id: string): Promise<boolean>

Removes a stored session.

isHealthy(): Promise<boolean>

Reports the store's reachability, for the plugin's health indicator.

Optional: a store with no meaningful liveness check omits it, and the indicator then reports only that a store is configured.

read(id: string): Promise<SessionData | null>

Reads a stored session payload.

sweep(): void

Drops every expired entry. Exposed so the sweep is directly testable.

write(
id: string,
data: SessionData,
ttlMs: number
): Promise<void>

Writes a session payload, replacing any existing one.

Usage

import { MemorySessionStore } from "session-plugin/src/index.ts";