FileSessionStore class
A dart:io file-system backed session snapshot store.
Snapshots are stored as flat JSON files keyed by their snapshotId, under an
optional per-tenant sub-directory prefix:
dirPath/<prefix>/<snapshotId>.json
getSnapshot(sessionId: ...) resolves the session's current leaf via a tiny
per-session pointer file (<prefix>/.pointers/<sessionId>.json, see
_PointerDoc) - one pointer read plus one snapshot read. When the pointer is
missing (e.g. a legacy store) or stale it transparently falls back to
scanning the prefix directory and selecting the single leaf whose
sessionId matches, then rewrites the pointer so subsequent lookups are fast
again.
- Implemented types
Constructors
-
FileSessionStore(String dirPath, {int? maxPersistedChainLength, String snapshotPathPrefix(Map<
String, dynamic> ? context)?, bool rejectBranchingSessions = false, Duration snapshotWatchPollInterval = _defaultSnapshotWatchPollInterval}) -
Creates a file-backed store rooted at
dirPath(created if missing).
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxPersistedChainLength → int?
-
When set, a chain longer than this is trimmed (oldest first) on each save.
final
- rejectBranchingSessions → bool
-
Whether a branched
sessionIdlookup is rejected instead of resolving to the most-recent leaf.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
snapshotPathPrefix
→ String Function(Map<
String, dynamic> ? context)? -
Derives the per-tenant sub-directory prefix from the call's
context.final
Methods
-
getSnapshot(
{String? snapshotId, String? sessionId, Map< String, dynamic> ? context}) → Future<SessionSnapshot?> -
Loads a snapshot either by its
snapshotIdor bysessionId.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onSnapshotStateChange(
String snapshotId, void callback(SessionSnapshot snapshot), {Map< String, dynamic> ? context}) → void Function()? -
Watches a single snapshot file for changes and invokes
callbackwith the parsed snapshot whenever it changes.override -
saveSnapshot(
String? snapshotId, SnapshotMutator mutator, {Map< String, dynamic> ? context}) → Future<String?> -
Atomically reads the current snapshot (if
snapshotIdis provided), passes it tomutator, and persists the result.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited