
Node Details
- Name:
redisCache
- Type:
RedisCache
- Category: [[Cache]]
- Version: 1.0
Parameters
-
Credential (Optional)
- Type: credential
- Credential Names: redisCacheApi, redisCacheUrlApi
- Description: The credentials required to connect to the Redis server.
-
Time to Live (ms) (Optional)
- Type: number
- Name: ttl
- Description: The time-to-live for cached items in milliseconds.
- Step: 1
- Additional Params: true
Input
The node doesn’t require direct input from the user. It integrates into the LLM query flow automatically.Output
The node returns aLangchainRedisCache
object, which can be used as a cache backend for LangChain operations.
How It Works
- The node initializes a connection to the Redis server using the provided credentials.
- When a query is made to an LLM:
- The cache checks if an identical query has been processed before.
- If found, it returns the cached response immediately.
- If not found, the query is processed by the LLM, and the response is stored in the Redis cache before being returned.
- The cache uses a combination of the prompt and LLM key to create unique cache keys.
- If a TTL is specified, cached items will expire after the set duration.
Use Cases
- Improving response times for frequently asked questions across multiple application instances
- Reducing API costs by minimizing redundant LLM calls in distributed systems
- Enhancing user experience in scalable chatbots or AI assistants with quicker responses
- Optimizing performance in scenarios with repetitive queries across different user sessions
- Sharing cache across multiple processes or servers
Special Features
- Distributed Caching: Utilizes Redis for cross-instance caching.
- Persistence: Cache can persist beyond individual application sessions.
- Configurable TTL: Supports setting Time-To-Live for cached items.
- Flexible Connection: Supports both direct Redis configuration and URL-based connection.
- SSL Support: Offers secure connections to Redis servers.
Notes
- Requires access to a Redis server, either self-hosted or cloud-based.
- The cache persists across application restarts, ensuring continuity of cached responses.
- This caching mechanism is particularly useful for scenarios where the same or similar queries are likely to occur across different sessions or application instances.
- While improving performance, it’s important to consider that cached responses may not reflect real-time changes or updates to the underlying LLM.
- The effectiveness of the cache depends on the nature of the queries and the likelihood of repetition across different users or sessions.
- The node supports both standalone Redis setups and clustered environments.