langchain.js
    Preparing search index...

    A cache for storing LLM generations that stores data in memory.

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    keyEncoder: HashKeyEncoder = defaultHashKeyEncoder

    Methods

    • Retrieves data from the cache using a prompt and an LLM key. If the data is not found, it returns null.

      Parameters

      • prompt: string

        The prompt used to find the data.

      • llmKey: string

        The LLM key used to find the data.

      Returns Promise<null | T>

      The data corresponding to the prompt and LLM key, or null if not found.

    • Sets a custom key encoder function for the cache. This function should take a prompt and an LLM key and return a string that will be used as the cache key.

      Parameters

      Returns void

    • Updates the cache with new data using a prompt and an LLM key.

      Parameters

      • prompt: string

        The prompt used to store the data.

      • llmKey: string

        The LLM key used to store the data.

      • value: T

        The data to be stored.

      Returns Promise<void>

    • Returns a global instance of InMemoryCache using a predefined global map as the initial cache.

      Returns InMemoryCache

      A global instance of InMemoryCache.