Interface ExpiringStorage<TKey, TValue>

A KeyValueStorage in which the values can expire. Entries with no expiration date never expire.

interface ExpiringStorage<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, expiration?: number): Promise<ExpiringStorage<TKey, TValue>>;
    set(key: TKey, value: TValue, expires?: Date): Promise<ExpiringStorage<TKey, TValue>>;
}

Type Parameters

  • TKey
  • TValue

Hierarchy (view full)

Implemented by

Properties

Methods

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.

Methods