@statesync/persistence / MemoryStorageBackendOptions
Interface: MemoryStorageBackendOptions
Defined in: persistence/src/storage/memory-storage.ts:12
Configuration options for the in-memory storage backend.
Provides fine-grained control over simulated behaviors including latency, error injection, and quota limits. Designed primarily for use in unit tests and integration tests where a real browser storage API is unavailable or where deterministic control over storage behavior is required.
Properties
errorMessage?
optional errorMessage: string;Defined in: persistence/src/storage/memory-storage.ts:59
Custom error message used when failOnSave or failOnLoad is enabled.
Default
'Simulated storage error'failOnLoad?
optional failOnLoad: boolean;Defined in: persistence/src/storage/memory-storage.ts:52
When true, all load operations will throw an error with the configured errorMessage.
Useful for testing graceful degradation when stored data cannot be retrieved.
Default
falsefailOnSave?
optional failOnSave: boolean;Defined in: persistence/src/storage/memory-storage.ts:42
When true, all save operations will throw an error with the configured errorMessage.
Useful for testing error handling and retry logic in persistence layers.
Default
falseinitialSnapshot?
optional initialSnapshot: SnapshotEnvelope<unknown>;Defined in: persistence/src/storage/memory-storage.ts:20
An initial snapshot to pre-populate the storage with on creation.
When provided, the storage will behave as if a save had already occurred with this snapshot. Default metadata (current timestamp, schema version 1, uncompressed) is generated automatically.
latencyMs?
optional latencyMs: number;Defined in: persistence/src/storage/memory-storage.ts:32
Simulated latency in milliseconds applied to every storage operation.
When set to a positive value, all save, load, clear, saveWithMetadata, and loadWithMetadata operations will be delayed by this duration before executing. Useful for testing loading states, race conditions, and timeout handling in consuming code.
Default
0maxSizeBytes?
optional maxSizeBytes: number;Defined in: persistence/src/storage/memory-storage.ts:68
Maximum allowed storage size in bytes, simulating a storage quota.
When set, save operations will throw an error if the serialized snapshot size exceeds this limit, mimicking the QuotaExceededError behavior of browser storage APIs.
