[]previous and next page

KVStore

The key-value store.

The key-value store. Every method is asynchronous, so a store may live in another process.

Import#

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

Signature#

ts
interface KVStore {
  /** The value under `key`, or `undefined` when there is none (or it expired). */
  get(key: string): Promise<unknown>;
  /** Stores `value` under `key`, replacing any value there. */
  set(key: string, value: unknown, options?: KVWriteOptions): Promise<void>;
  /** Removes `key`. A missing key is not an error. */
  delete(key: string): Promise<void>;
  /** The keys with a prefix, one page at a time. */
  list(options?: KVListOptions): Promise<KVListPage>;
  /** Adds `by` to the number under `key` and returns the new value. */
  increment(key: string, by?: number, options?: KVWriteOptions): Promise<number>;
}

Members#

Name Type Description
get get(key: string): Promise<unknown> The value under key, or undefined when there is none (or it expired).
set set(key: string, value: unknown, options?: KVWriteOptions): Promise<void> Stores value under key, replacing any value there.
delete delete(key: string): Promise<void> Removes key. A missing key is not an error.
list list(options?: KVListOptions): Promise<KVListPage> The keys with a prefix, one page at a time.
increment increment(key: string, by?: number, options?: KVWriteOptions): Promise<number> Adds by to the number under key and returns the new value.