Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Index

Constructors

Properties

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

Methods

  • delete(key: TKey): Promise<boolean>
  • entries(): AsyncIterableIterator<[TKey, TValue]>
  • finalize(): Promise<void>
  • get(key: TKey): Promise<undefined | TValue>
  • getUnexpired(key: TKey): Promise<undefined | TValue>
  • 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>

  • has(key: TKey): Promise<boolean>
  • isExpired(expires?: Date): boolean
  • removeExpiredEntries(): Promise<void>
  • toData(expireData: Expires<TValue>): { expires?: Date; payload: TValue }
  • toExpires(data: TValue, expires?: Date): Expires<TValue>