Remote / foldkit-remote/persistence

PersistenceOptions

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

interface PersistenceOptions<AppModel> {
  readonly key: (model: AppModel) => string
  readonly scope: (model: AppModel) => string
  readonly connections?: ReadonlyArray<ConnectionIdentity> | undefined
  readonly maxAge?: number | undefined
  readonly snapshot?:
    | ((
        remote: RemoteModel,
        options: {
          readonly maxAge: number
        },
      ) => Snapshot)
    | undefined
  readonly maxBytes?: number | undefined
  readonly debounce?: Duration.Input | undefined
}

How persistence keeps the cache across a reload.

Members

PersistenceOptions.key

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

readonly key: (model: AppModel) => string

Where the snapshot is stored, from the Model: one key per principal, so a change of principal reads and writes another snapshot.

PersistenceOptions.scope

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

readonly scope: (model: AppModel) => string

Who the snapshot is for; one taken under another scope is discarded.

PersistenceOptions.connections

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

readonly connections?: ReadonlyArray<ConnectionIdentity> | undefined

The query connections whose rows survive a reload; none by default.

PersistenceOptions.maxAge

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

readonly maxAge?: number | undefined

How long a saved row or list lasts, in milliseconds from when it was fetched, unless the call reading it says (Data.subscriptions' persist). Restoring it does not make it younger. Default one day.

PersistenceOptions.snapshot

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

readonly snapshot?:
  | ((
      remote: RemoteModel,
      options: {
        readonly maxAge: number
      },
    ) => Snapshot)
  | undefined

What to keep, when it is not snapshotOf the connections; build it with snapshotOf and the maxAge given.

PersistenceOptions.maxBytes

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

readonly maxBytes?: number | undefined

The most bytes a snapshot takes; past it, what was read least recently goes first.

PersistenceOptions.debounce

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

readonly debounce?: Duration.Input | undefined

How long the cache must be unchanged before it is written; default 250 milliseconds.