A generic cache for storing and retrieving objects by string keys. ObjectCache

Uses a Map to efficiently cache objects, allowing retrieval, addition, and deletion by key.

Type Parameters

  • T

    The type of objects stored in the cache.

Constructors

Methods

Constructors

Methods

  • Removes an object from the cache by its key.

    Parameters

    • key: string

      The key of the object to remove.

    Returns void

  • Retrieves a cached object by its key.

    Parameters

    • key: string

      The key associated with the cached object.

    Returns undefined | T

    • The cached object if found, otherwise undefined.
  • Adds an object to the cache if it doesn’t already exist.

    Parameters

    • key: string

      The key to associate with the object.

    • value: T

      The object to cache.

    Returns void