Class LRUCache<K, V>

Type Parameters

  • K = string
  • V = unknown

Constructors

Properties

cache: Map<K, LRUCacheItem<V>> = ...
options: Required<LRUCacheOptions<K, V>>

Methods

  • Deletes a key out of the cache

    Parameters

    • key: K
    • reason: DisposeReason = 'delete'

    Returns boolean

  • Return a value from the cache

    Type Parameters

    • T = V

    Parameters

    • key: K
    • options: { updateAgeOnGet?: boolean } = {}

    Returns undefined | T

  • Returns { capacity: number; size: number }

    • capacity: number
    • size: number

      The total number of items held in the cache at the current moment

  • Add a value to the cache

    Type Parameters

    • T = V

    Parameters

    • key: K
    • value: T
    • Optionalopts: { ttl?: number }

    Returns void