Remote / foldkit-remote/persistence

Snapshot

interface · packages/remote/src/persistence.ts:81

interface Snapshot {
  readonly entities: EntityStore
  readonly connections: Readonly<Record<string, SavedList>>
  readonly expires: {
    readonly rows: Readonly<Record<EntityKey, number>>
    readonly lists: Readonly<Record<string, number>>
  }
  readonly recency: ReadonlyArray<SavedBatch>
}

What survives a reload: the entity cache, and the connections an application declared should come back.

Connections are session state by default and stay that way — snapshotOf takes none unless asked. What a declared one keeps is its edges and nothing else, which is not a simplification but the rule: a connection's boundaries are cursors the server minted, and a cursor may name server state that no longer exists. Restoring one would be claiming to know where the page ends. The shape has nowhere to put a cursor, so that cannot be got wrong later.

Members

Snapshot.entities

property · packages/remote/src/persistence.ts:82

readonly entities: EntityStore

Snapshot.connections

property · packages/remote/src/persistence.ts:84

readonly connections: Readonly<Record<string, SavedList>>

By connection identity.

Snapshot.expires

property · packages/remote/src/persistence.ts:90

readonly expires: {
  readonly rows: Readonly<Record<EntityKey, number>>
  readonly lists: Readonly<Record<string, number>>
}

When each row (by entity key) and list (by identity) expires, in clock milliseconds: what is no younger than its maxAge then is not written and not restored. One not named never expires.

Snapshot.recency

property · packages/remote/src/persistence.ts:100

readonly recency: ReadonlyArray<SavedBatch>

The batches of reads that reached the rows and lists, most recently read first. Past maxBytes the last go first; a row or list a kept batch also reaches stays. Empty when there is no order, and then a snapshot past maxBytes is not written at all.