Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ExpiringStorage<TKey, TValue>

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

Type parameters

  • TKey

  • TValue

Hierarchy

Implemented by

Index

Methods

  • 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>>
  • Sets the value for the given key. Should error if the data is already expired.

    Parameters

    • key: TKey

      Key to set/update.

    • value: TValue

      Value to store.

    • Optional expiration: number

      How long this data should stay valid in milliseconds.

    Returns Promise<ExpiringStorage<TKey, TValue>>

    The storage.

  • Sets the value for the given key. Should error if the data is already expired.

    Parameters

    • key: TKey

      Key to set/update.

    • value: TValue

      Value to store.

    • Optional expires: Date

      When this value expires. Never if undefined.

    Returns Promise<ExpiringStorage<TKey, TValue>>

    The storage.