Skip to content

In-memory snapshot store

InMemorySnapshotStore keeps snapshots in a Map<persistenceId, Snapshot[]> in process memory. Like InMemoryJournal, it’s the default when no snapshot store is configured — zero setup, ideal for tests, never use in production.

import { InMemorySnapshotStore, PersistenceExtensionId, ActorSystem } from 'actor-ts';
const system = ActorSystem.create('demo');
system.extension(PersistenceExtensionId).configure({
journal: new InMemoryJournal(),
snapshotStore: new InMemorySnapshotStore(),
});

Implements the SnapshotStore interface — save, loadLatest, deleteUpTo. Each persistenceId maps to an array of snapshots ordered by sequence number.

  • save(pid, snapshot) — append to the pid’s array.
  • loadLatest(pid) — return the highest-seq snapshot, or None.
  • deleteUpTo(pid, seqNr) — splice off snapshots with seq ≤ seqNr.

The implementation is reference semantics — every other snapshot store must match this behavior (modulo persistence / encryption / compression specifics).

  • Tests — fast, no IO, clean teardown per test.
  • Dev — when you don’t want a real snapshot file lying around between runs.
  • Reference for custom implementations — read the source for the contract.