Clear all entries in the Redis semantic cache.
This method removes all cache entries from the semantic cache.
clear(
self,
**kwargs: Any = {},
) -> NoneExample:
from langchain_openai import OpenAIEmbeddings
cache = RedisSemanticCache(
embeddings=OpenAIEmbeddings(),
redis_url="redis://localhost:6379",
name="my_semantic_cache"
)
# Add some entries to the cache
cache.update(
"What is the capital of France?",
"llm1",
[Generation(text="Paris")]
)
cache.update(
"Who wrote Romeo and Juliet?",
"llm2",
[Generation(text="Shakespeare")]
)
# Clear all entries
cache.clear()
# After this, all entries in the semantic cache will be removed
Note:
| Name | Type | Description |
|---|---|---|
**kwargs | Any | Default: {}Additional keyword arguments. Currently not used, but included for potential future extensions. |