Interface KV

interface KV {
    create(k: string, data: Payload): Promise<number>;
    delete(k: string, opts?: Partial<KvDeleteOptions>): Promise<void>;
    destroy(): Promise<boolean>;
    get(k: string, opts?: {
        revision: number;
    }): Promise<KvEntry>;
    history(opts?: {
        key?: string | string[];
    }): Promise<QueuedIterator<KvWatchEntry>>;
    keys(filter?: string | string[]): Promise<QueuedIterator<string>>;
    purge(k: string, opts?: Partial<KvDeleteOptions>): Promise<void>;
    put(k: string, data: Payload, opts?: Partial<KvPutOptions>): Promise<number>;
    status(): Promise<KvStatus>;
    update(k: string, data: Payload, version: number): Promise<number>;
    watch(opts?: KvWatchOptions): Promise<QueuedIterator<KvWatchEntry>>;
}

Hierarchy (view full)

Implemented by

Methods

  • Creates a new entry ensuring that the entry does not exist (or the current version is deleted or the key is purged) If the entry already exists, this operation fails.

    Parameters

    • k: string
    • data: Payload

    Returns Promise<number>

  • Deletes the entry stored under the specified key. Deletes are soft-deletes. The server will add a new entry marked by a "DEL" operation. Note that if the KV was created with an underlying limit (such as a TTL on keys) it is possible for a key or the soft delete marker to be removed without additional notification on a watch.

    Parameters

    Returns Promise<void>

  • Destroys the underlying stream used by the KV. This effectively deletes all data stored under the KV.

    Returns Promise<boolean>

  • Returns the KvEntry stored under the key if it exists or null if not. Note that the entry returned could be marked with a "DEL" or "PURGE" operation which signifies the server stored the value, but it is now deleted.

    Parameters

    • k: string
    • Optionalopts: {
          revision: number;
      }
      • revision: number

    Returns Promise<KvEntry>

  • Returns an iterator of the specified key's history (or all keys). Note you can specify multiple keys if running on server 2.10.x or better.

    Parameters

    • Optionalopts: {
          key?: string | string[];
      }
      • Optionalkey?: string | string[]

    Returns Promise<QueuedIterator<KvWatchEntry>>

  • Returns an iterator of all the keys optionally matching the specified filter.

    Parameters

    • Optionalfilter: string | string[]

      default is all keys

    Returns Promise<QueuedIterator<string>>

  • Deletes and purges the specified key and any value history.

    Parameters

    Returns Promise<void>

  • Sets or updates the value stored under the specified key.

    Parameters

    Returns Promise<number>

  • Returns information about the Kv

    Returns Promise<KvStatus>

  • Updates the existing entry provided that the previous sequence for the Kv is at the specified version. This ensures that the KV has not been modified prior to the update.

    Parameters

    • k: string
    • data: Payload
    • version: number

    Returns Promise<number>

  • Returns an iterator that will yield KvEntry updates as they happen.

    Parameters

    Returns Promise<QueuedIterator<KvWatchEntry>>