Remote / API

foldkit-remote/persistence

foldkit-remote/persistence, an entry of its own (#378). Remote cache persistence: a snapshot of the entity store and nothing else. Runtime state (connections' live cursors, optimistic layers, the mutation ledger, gaps, retention roots) is never in a snapshot; it belongs to the session that produced it.

The cache is server-derived and disposable: an incompatible, oversized, or corrupt snapshot is discarded (and removed from a KeyValueStore) so the planner refetches. dehydrate/hydrate are the string forms, for SSR and any other transport; save/restore put them behind Effect's KeyValueStore, so the backend (memory, filesystem, SQL, Web Storage) is the application's choice.

Each row and list saved carries when it expires: when it was fetched plus the maxAge of the calls that read it (persist). What has expired is dropped when a snapshot is written and again when it is read, and a snapshot past maxBytes drops what was read least recently first.

Namespaces

Functions

persistenceKeeps a domain's cache across a reload, as a wiring beside Data.wiring: the stored snapshot for key is restored (Hydrated, with what the store already holds…

Values

REMOTE_CACHE_VERSIONBump when the serialized shape changes; a mismatch discards the cache.

Interfaces

ClockedOptionsdehydrate's and hydrate's options: SnapshotOptions, and the time to judge ages at.
PersistedDomainWhat persistence uses of a domain: Remote.make's value is one.
PersistenceOptionsHow persistence keeps the cache across a reload.
PersistenceWiringpersistence's wiring, and the restore its runtime's init starts from.
SavedBatchThe rows and lists one batch of reads reached: what is kept or dropped together.
SavedListA list kept across a reload: its edges, and its age.
SnapshotWhat survives a reload: the entity cache, and the connections an application declared should come back.
SnapshotOptions
SnapshottedWhat snapshotOf reads of a Model.