⚠️ Deprecated ⚠️

This feature is deprecated and will be removed in the future.

It is not recommended for use.

Import from "@langchain/community/caches/ioredis" instead. Represents a specific implementation of a caching mechanism using Redis as the underlying storage system. It extends the BaseCache class and overrides its methods to provide the Redis-specific logic.

Example

const model = new ChatOpenAI({
cache: new RedisCache(new Redis(), { ttl: 60 }),
});

// Invoke the model to perform an action
const response = await model.invoke("Do something random!");
console.log(response);

Hierarchy (view full)

Constructors

Methods

Constructors

Methods

  • Retrieves data from the cache. It constructs a cache key from the given prompt and llmKey, and retrieves the corresponding value from the Redis database.

    Parameters

    • prompt: string

      The prompt used to construct the cache key.

    • llmKey: string

      The LLM key used to construct the cache key.

    Returns Promise<null | Generation[]>

    An array of Generations if found, null otherwise.

  • Updates the cache with new data. It constructs a cache key from the given prompt and llmKey, and stores the value in the Redis database.

    Parameters

    • prompt: string

      The prompt used to construct the cache key.

    • llmKey: string

      The LLM key used to construct the cache key.

    • value: Generation[]

      The value to be stored in the cache.

    Returns Promise<void>

Generated using TypeDoc