Interface KeyValueStorage<TKey, TValue>

A simple storage solution that can be used for internal values that need to be stored. To prevent potential issues, keys should be urlencoded before calling the storage.

interface KeyValueStorage<TKey, TValue> {
    delete: ((key: TKey) => Promise<boolean>);
    entries: (() => AsyncIterableIterator<[TKey, TValue]>);
    get: ((key: TKey) => Promise<undefined | TValue>);
    has: ((key: TKey) => Promise<boolean>);
    set: ((key: TKey, value: TValue) => Promise<KeyValueStorage<TKey, TValue>>);
}

Type Parameters

  • TKey
  • TValue

Hierarchy (view full)

Implemented by

Properties

Properties

delete: ((key: TKey) => Promise<boolean>)

Deletes the value stored for the given key.

Type declaration

    • (key): Promise<boolean>
    • Parameters

      • key: TKey

        Key to delete.

      Returns Promise<boolean>

      If there was a value to delete.

entries: (() => AsyncIterableIterator<[TKey, TValue]>)

An iterable of entries in the storage.

get: ((key: TKey) => Promise<undefined | TValue>)

Returns the value stored for the given identifier. undefined if no value is stored.

has: ((key: TKey) => Promise<boolean>)

Checks whether there is a value stored for the given key.

set: ((key: TKey, value: TValue) => Promise<KeyValueStorage<TKey, TValue>>)

Sets the value for the given key.

Type declaration