Class WrappedExpiringStorage<TKey, TValue>

A storage that wraps around another storage and expires resources based on the given (optional) expiry date. Will delete expired entries when trying to get their value. Has a timer that will delete all expired data every hour (default value).

Type Parameters

  • TKey

  • TValue

Hierarchy

  • WrappedExpiringStorage

Implements

Constructors

Properties

logger: Logger = ...
source: KeyValueStorage<TKey, Expires<TValue>>
timer: Timeout

Methods

  • Tries to get the data for the given key. In case the data exists but has expired, it will be deleted and undefined will be returned instead.

    Parameters

    • key: TKey

    Returns Promise<undefined | TValue>

  • Creates a new object where the expires field is a Date instead of a string.

    Parameters

    Returns {
        expires?: Date;
        payload: TValue;
    }

    • Optional expires?: Date
    • payload: TValue