Class CacheMap<TKey, TValue>

Compared to a Map with a helper method:

  • Avoids allocation of item factory (+ its closure) on each get.
  • If TValue is a promise then all callers get the same one -> safe for parallelism.

Deprecated

Use getOrCreate instead.

Type Parameters

  • TKey

  • TValue

Hierarchy

  • CacheMap

Constructors

Methods

Constructors

  • Type Parameters

    • TKey

    • TValue

    Parameters

    • options: {
          itemFactory: ((key: TKey) => TValue);
          stringifyKey: ((key: TKey) => string);
      }
      • itemFactory: ((key: TKey) => TValue)
          • (key: TKey): TValue
          • Parameters

            • key: TKey

            Returns TValue

      • stringifyKey: ((key: TKey) => string)
          • (key: TKey): string
          • Parameters

            • key: TKey

            Returns string

    Returns CacheMap<TKey, TValue>

Methods

  • Parameters

    • key: TKey

    Returns TValue

Generated using TypeDoc