Simple cache by ID.

Type Parameters

  • T

Hierarchy (View Summary)

Constructors

Accessors

Methods

Constructors

  • Construct this, with an optional cache passthrough method. Use this to add idempotency to memoized objects where needed, such as cloning them or locking them.

    Type Parameters

    • T

    Parameters

    • OptionalcachePassthrough: (from: T) => T

    Returns default<T>

Accessors

  • get length(): number
  • Get the number of memoized items

    Returns number

    The number of items memoized in this.

Methods

  • Iterate through the cached objects

    Returns IterableIterator<[number, T]>

    Iterate over this.

  • Add an item to the cache.

    Parameters

    • id: number
    • value: T
    • temporary: boolean = false

    Returns void

  • Delete an item from the cache.

    Parameters

    • id: number

    Returns boolean

    True if the item was in the cache.