A basic TTL cache with configurable TTL and check interval.

Hierarchy

  • TtlCache

Constructors

Properties

_checkIntervalHandle: any
_options: TtlCacheOptions
_storage: Map<string, CacheRecord> = ...

Accessors

Methods

  • Delete the item with the specific key. If the item does not exist, then there will be no change to the cache.

    Parameters

    • key: string

      The key of the value to delete.

    Returns void

  • Get a value from the cache.

    Parameters

    • key: string

      The key to get a value for.

    Returns any

    The value for the key, or undefined if the key was not added, or if the value has expired.

  • Set an item in the cache. It will expire after the TTL specified in the cache configuration.

    Parameters

    • key: string

      The key for the value.

    • value: any

      The value to set.

    Returns void

Generated using TypeDoc