(example below).Cache‚ÄãThe Cache wrapper allows for Redis to be used as a remote, low-latency, in-memory cache for LLM prompts and responses.Standard Cache‚ÄãThe standard cache is the Redis bread & butter of use case in production for both open-source and enterprise users globally.To import this cache:from langchain.cache import RedisCacheTo use this cache with your LLMs:from langchain.globals import set_llm_cacheimport redisredis_client = redis.Redis.from_url(...)set_llm_cache(RedisCache(redis_client))Semantic Cache‚ÄãSemantic caching allows users to retrieve cached prompts based on semantic similarity between the user input and previously cached results. Under the hood it blends Redis as both a cache and a vectorstore.To import this cache:from langchain.cache import RedisSemanticCacheTo use this cache with your LLMs:from langchain.globals import set_llm_cacheimport redis# use any embedding provider...from tests.integration_tests.vectorstores.fake_embeddings import FakeEmbeddingsredis_url = "redis://localhost:6379"set_llm_cache(RedisSemanticCache(    embedding=FakeEmbeddings(),    redis_url=redis_url))VectorStore‚ÄãThe vectorstore wrapper turns Redis into a low-latency vector database for semantic search or LLM content retrieval.To import this vectorstore:from langchain.vectorstores import RedisFor a more detailed walkthrough of the Redis vectorstore wrapper, see this notebook.Retriever‚ÄãThe Redis vector store retriever wrapper generalizes the vectorstore class to perform low-latency document retrieval. To create the retriever, simply call .as_retriever() on the base vectorstore class.Memory‚ÄãRedis can be used to persist LLM conversations.Vector Store Retriever Memory‚ÄãFor a more detailed walkthrough of the VectorStoreRetrieverMemory wrapper, see this notebook.Chat Message History Memory‚ÄãFor a detailed example of Redis to cache conversation message history, see this notebook.PreviousRedditNextReplicateInstallation and SetupWrappersRedis Standalone connection
Redis (Remote Dictionary Server) is an open-source in-memory storage,
Redis (Remote Dictionary Server) is an open-source in-memory storage, ->: (example below).Cache‚ÄãThe Cache wrapper allows for Redis to be used as a remote, low-latency, in-memory cache for LLM prompts and responses.Standard Cache‚ÄãThe standard cache is the Redis bread & butter of use case in production for both open-source and enterprise users globally.To import this cache:from langchain.cache import RedisCacheTo use this cache with your LLMs:from langchain.globals import set_llm_cacheimport redisredis_client = redis.Redis.from_url(...)set_llm_cache(RedisCache(redis_client))Semantic Cache‚ÄãSemantic caching allows users to retrieve cached prompts based on semantic similarity between the user input and previously cached results. Under the hood it blends Redis as both a cache and a vectorstore.To import this cache:from langchain.cache import RedisSemanticCacheTo use this cache with your LLMs:from langchain.globals import set_llm_cacheimport redis# use any embedding provider...from tests.integration_tests.vectorstores.fake_embeddings import FakeEmbeddingsredis_url = "redis://localhost:6379"set_llm_cache(RedisSemanticCache(    embedding=FakeEmbeddings(),    redis_url=redis_url))VectorStore‚ÄãThe vectorstore wrapper turns Redis into a low-latency vector database for semantic search or LLM content retrieval.To import this vectorstore:from langchain.vectorstores import RedisFor a more detailed walkthrough of the Redis vectorstore wrapper, see this notebook.Retriever‚ÄãThe Redis vector store retriever wrapper generalizes the vectorstore class to perform low-latency document retrieval. To create the retriever, simply call .as_retriever() on the base vectorstore class.Memory‚ÄãRedis can be used to persist LLM conversations.Vector Store Retriever Memory‚ÄãFor a more detailed walkthrough of the VectorStoreRetrieverMemory wrapper, see this notebook.Chat Message History Memory‚ÄãFor a detailed example of Redis to cache conversation message history, see this notebook.PreviousRedditNextReplicateInstallation and SetupWrappersRedis Standalone connection