| Name | Type | Description |
|---|---|---|
redis_url | str | Default: 'redis://localhost:6379'The URL of the Redis instance to connect to. Defaults to "redis://localhost:6379". |
ttl | Optional[int] | Default: NoneTime-to-live for cache entries in seconds. Defaults to None (no expiration). |
prefix | Optional[str] | Default: 'redis' |
redis* | Optional[Redis] |
Redis cache implementation for LangChain.
This class provides a Redis-based caching mechanism for LangChain, allowing storage and retrieval of language model responses.
Example:
.. code-block:: python
from langchain_redis import RedisCache from langchain_core.globals import set_llm_cache
redis_cache = RedisCache(redis_url="redis://localhost:6379", ttl=3600)
set_llm_cache(redis_cache)
Note:
Prefix for all keys stored in Redis. Defaults to "redis".
An existing Redis client instance. If provided, redis_url is ignored.