PersistSessionUtils

Utility class for managing session persistence.

Features:

  • Memoized storage instances per (strategyName, exchangeName, frameName) key
  • Custom adapter support
  • Atomic read/write operations

Storage layout: ./dump/session/<strategyName>/<exchangeName>/<frameName>.json

Used by SessionPersistInstance for crash-safe session persistence.

constructor();
PersistSessionFactory: any
getSessionStorage: any
waitForInit: (strategyName: string, exchangeName: string, frameName: string, initial: boolean) => Promise<void>

Initializes the storage for a given (strategyName, exchangeName, frameName) triple.

readSessionData: (strategyName: string, exchangeName: string, frameName: string) => Promise<SessionData>

Reads a session entry from persistence storage.

writeSessionData: (data: SessionData, strategyName: string, exchangeName: string, frameName: string) => Promise<void>

Writes a session entry to disk with atomic file writes.

useDummy: () => void

Switches to a dummy persist adapter that discards all writes. All future persistence writes will be no-ops.

useJson: () => void

Switches to the default JSON persist adapter. All future persistence writes will use JSON storage.

clear: () => void

Clears the memoized storage cache. Call this when process.cwd() changes between strategy iterations so new storage instances are created with the updated base path.

dispose: (strategyName: string, exchangeName: string, frameName: string) => void

Disposes of the session adapter and releases any resources. Call this when a session is removed to clean up its associated storage.

usePersistSessionAdapter(Ctor: TPersistBaseCtor<string, SessionData>): void;

Registers a custom persistence adapter.