Remote / foldkit-remote/persistence

persistence

function · packages/remote/src/persistence.ts:735

function persistence<AppModel>(
  domain: PersistedDomain<AppModel>,
  options: PersistenceOptions<AppModel>,
): PersistenceWiring<AppModel>

Keeps 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 kept over it, so a page resumed from the server wins) whenever the Model is not yet restored from key; and the cache is written back when it changes, once its own snapshot is in. Start init from its restore so the first frame already holds the snapshot. Each saved row and list lasts maxAge from when it was fetched; past maxBytes, what was read least recently goes first. Overlays, optimistic layers, the mutation ledger, live cursors and gaps are never stored. A change of principal should forget in update, and name another key.