[]previous and next page

createMemoryKVStore

The in-process store: a bounded least-recently-used table of JSON text.

The in-process store: a bounded least-recently-used table of JSON text. It is the default for the page cache, the data cache, sessions and rate limits of a single process.

Import#

ts
import { createMemoryKVStore } from "@shadow-js/dusk/server";

Signature#

ts
function createMemoryKVStore(
  options: MemoryKVStoreOptions = {},
): KVStore & { readonly size: number }

Parameters#

Name Description
options The bounds and the clock.

Returns#

The store, with a size for tests and metrics.

Throws#

  • RangeError for a bound that is not a positive integer.

Examples#

ts
const kv = createMemoryKVStore({ maxEntries: 5_000 });
await kv.set("greeting", { text: "hi" }, { ttlSeconds: 60 });