
Redis Semantic Cache
- 909 installs
- 94 repo stars
- Updated July 9, 2026
- redis/agent-skills
Redis LangCache guidance for semantic caching of LLM responses on Redis Cloud — calling search/set via the SDK or REST API, tuning the similarity threshold, separating caches per task type, and filtering with custom attr
About
Redis LangCache guidance for semantic caching of LLM responses on Redis Cloud — calling search/set via the SDK or REST API, tuning the similarity threshold, separating caches per task type, and filtering with custom attributes. Use when caching LLM completions or RAG answers to cut API cost and latency, building a cache-aside layer in front of OpenAI / Anthropic / etc., tuning hit rate vs precision, or splitting one app's LLM workloads into multiple LangCache caches. Semantic caching for LLM responses with Redis Cloud's LangCache service. Stores prompts as embeddings; subsequent semantically-similar prompts return the cached response without re-calling the model.
- > LangCache is currently in **preview** on Redis Cloud. Features and behavior may change.
- Wrapping an LLM call (OpenAI, Anthropic, etc.) with a cache layer to cut cost and latency.
- Caching RAG answers, classification outputs, or any deterministic LLM workload.
- Tuning the precision/hit-rate trade-off for a semantic cache.
- Splitting one application's LLM workloads across multiple cache instances.
Redis Semantic Cache by the numbers
- 909 all-time installs (skills.sh)
- +87 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #1,205 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
redis-semantic-cache capabilities & compatibility
- Capabilities
- > langcache is currently in **preview** on redis · wrapping an llm call (openai, anthropic, etc.) w · caching rag answers, classification outputs, or · tuning the precision/hit rate trade off for a se
- Use cases
- documentation
What redis-semantic-cache says it does
Redis LangCache guidance for semantic caching of LLM responses on Redis Cloud — calling search/set via the SDK or REST API, tuning the similarity threshold, separating caches per task type, and filter
npx skills add https://github.com/redis/agent-skills --skill redis-semantic-cacheAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 909 |
|---|---|
| repo stars | ★ 94 |
| Last updated | July 9, 2026 |
| Repository | redis/agent-skills ↗ |
How do I apply redis-semantic-cache using the workflow in its SKILL.md?
Redis LangCache guidance for semantic caching of LLM responses on Redis Cloud — calling search/set via the SDK or REST API, tuning the similarity threshold, separating caches per task typ...
Who is it for?
Developers following the redis-semantic-cache skill for the tasks it documents.
Skip if: Tasks outside the redis-semantic-cache scope described in SKILL.md.
When should I use this skill?
User mentions redis-semantic-cache or related triggers from the skill description.
What you get
Working redis-semantic-cache setup aligned with the documented patterns and constraints.
- LangCache configuration
- Similarity threshold settings
- Per-task cache separation
By the numbers
- Version 1.0.0 in redis/agent-skills manifest
- LangCache is in preview on Redis Cloud
Files
Redis Semantic Cache
Semantic caching for LLM responses with Redis Cloud's LangCache service. Stores prompts as embeddings; subsequent semantically-similar prompts return the cached response without re-calling the model.
LangCache is currently in preview on Redis Cloud. Features and behavior may change.
When to apply
- Wrapping an LLM call (OpenAI, Anthropic, etc.) with a cache layer to cut cost and latency.
- Caching RAG answers, classification outputs, or any deterministic LLM workload.
- Tuning the precision/hit-rate trade-off for a semantic cache.
- Splitting one application's LLM workloads across multiple cache instances.
1. The cache-aside flow
LangCache fits in front of any LLM call as a standard cache-aside pattern:
1. Send the user's prompt to LangCache's search. 2. Cache hit — return the stored response directly. 3. Cache miss — call the LLM, then set the response so future similar prompts hit.
from langcache import LangCache
import os
lang_cache = LangCache(
server_url=f"https://{os.getenv('HOST')}",
cache_id=os.getenv("CACHE_ID"),
api_key=os.getenv("API_KEY"),
)
result = lang_cache.search(prompt="What is Redis?", similarity_threshold=0.9)
if result:
response = result[0]["response"]
else:
response = llm.generate("What is Redis?")
lang_cache.set(prompt="What is Redis?", response=response)The same operations are available via REST (POST /v1/caches/{cacheId}/entries/search and POST /v1/caches/{cacheId}/entries) when an SDK isn't an option.
See references/langcache-usage.md for full SDK + REST samples and attribute-based storage.
2. Tune the similarity threshold
The threshold controls how close (in embedding cosine distance) a new prompt must be to a cached one to count as a hit. Higher = stricter match, fewer false positives. Lower = more hits, more risk of returning an off-topic answer.
| Threshold | Behavior | Use when |
|---|---|---|
| 0.95+ | Near-exact match required | Customer-facing answers where wrong responses are costly |
| 0.9 | Balanced default | Most workloads — start here |
| 0.8 | Loose semantic match | Internal tools, exploratory queries, FAQ deduplication |
# Stricter — fewer false positives
result = lang_cache.search(prompt="What is Redis?", similarity_threshold=0.95)
# Looser — higher hit rate
result = lang_cache.search(prompt="What is Redis?", similarity_threshold=0.8)Adjust by watching the actual cache-hit rate and spot-checking that returned answers are still relevant.
See references/best-practices.md.
3. Separate caches per task type
Different LLM workloads should not share one cache — a "code question" prompt is semantically close to other code questions but has nothing to do with a password-reset support query, and crossing them returns garbage.
support_cache = LangCache(server_url=..., cache_id="support-cache-id", api_key=...)
code_cache = LangCache(server_url=..., cache_id="code-cache-id", api_key=...)Create distinct cache IDs in Redis Cloud per task, and route each call to the right one. As a finer-grained alternative, store and search with custom attributes (e.g. {"category": "database"}) to keep tasks in the same cache but isolated by attribute filter — useful when the same prompt format spans subtopics.
References
{
"name": "redis-semantic-cache",
"version": "1.0.0",
"description": "Redis LangCache — cache-aside flow for LLM responses, similarity threshold tuning, per-task cache separation.",
"author": {
"name": "Redis",
"email": "support@redis.com"
},
"homepage": "https://redis.io",
"repository": "https://github.com/redis/agent-skills",
"license": "MIT",
"keywords": ["redis", "semantic-cache", "langcache", "llm", "ai"]
}
Configure Semantic Cache Properly
Note: LangCache is currently in preview on Redis Cloud. Features and behavior may change.
Tune similarity threshold and cache separation for optimal LangCache results.
Correct: Tune similarity threshold for your use case.
from langcache import LangCache
lang_cache = LangCache(
server_url=f"https://{os.getenv('HOST')}",
cache_id=os.getenv("CACHE_ID"),
api_key=os.getenv("API_KEY")
)
# Stricter matching - fewer false positives (0.95 = very similar)
result = lang_cache.search(
prompt="What is Redis?",
similarity_threshold=0.95
)
# Looser matching - higher hit rate (0.8 = somewhat similar)
result = lang_cache.search(
prompt="What is Redis?",
similarity_threshold=0.8
)Correct: Use separate caches for different use cases.
# Create different cache IDs in Redis Cloud for different LLM tasks
support_cache = LangCache(
server_url=server_url,
cache_id="support-cache-id",
api_key=api_key
)
code_cache = LangCache(
server_url=server_url,
cache_id="code-cache-id",
api_key=api_key
)Incorrect: Using a single cache for all LLM tasks.
# All tasks share one cache - responses may not be relevant
result = lang_cache.search(prompt="How do I reset my password?")
# Could return a code snippet if someone asked a similar coding questionBest practices:
- Start with threshold 0.9, adjust based on your use case
- Use custom attributes to filter results within a single cache
- Monitor cache hit rates to evaluate effectiveness
- Use separate cache IDs for fundamentally different LLM tasks
Reference: LangCache Best Practices
Use LangCache for LLM Response Caching
Note: LangCache is currently in preview on Redis Cloud. Features and behavior may change.
LangCache is a fully-managed semantic caching service on Redis Cloud that reduces LLM costs and latency.
How it works: 1. Your app sends a prompt to LangCache via POST /v1/caches/{cacheId}/entries/search 2. LangCache generates an embedding and searches for similar cached responses 3. If found (cache hit), returns the cached response instantly 4. If not found (cache miss), your app calls the LLM and stores the response
Correct: Use the LangCache Python SDK.
from langcache import LangCache
import os
lang_cache = LangCache(
server_url=f"https://{os.getenv('HOST')}",
cache_id=os.getenv("CACHE_ID"),
api_key=os.getenv("API_KEY")
)
# Search for cached response
result = lang_cache.search(
prompt="What is Redis?",
similarity_threshold=0.9
)
if result:
response = result[0]["response"]
else:
response = llm.generate("What is Redis?")
# Store for future queries
lang_cache.set(
prompt="What is Redis?",
response=response
)LangCache REST API:
# Search cache
curl -X POST "https://$HOST/v1/caches/$CACHE_ID/entries/search" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt": "What is Redis?"}'
# Store a response
curl -X POST "https://$HOST/v1/caches/$CACHE_ID/entries" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt": "What is Redis?", "response": "Redis is an in-memory database..."}'With custom attributes for filtering:
# Store with attributes
lang_cache.set(
prompt="What is Redis?",
response="Redis is an in-memory database...",
attributes={"category": "database", "version": "v1"}
)
# Search with attribute filter
result = lang_cache.search(
prompt="Tell me about Redis",
attributes={"category": "database"},
similarity_threshold=0.9
)Reference: LangCache Documentation
Related skills
How it compares
Pick redis-semantic-cache for semantic similarity LLM caching on Redis rather than generic in-memory exact-match caches.
FAQ
What does redis-semantic-cache do?
Redis LangCache guidance for semantic caching of LLM responses on Redis Cloud — calling search/set via the SDK or REST API, tuning the similarity threshold, separating caches per task typ...
When should I use redis-semantic-cache?
Invoke when Redis LangCache guidance for semantic caching of LLM responses on Redis Cloud — calling search/set via the SDK or REST API, tuning the simil.
Is redis-semantic-cache safe to install?
Review the Security Audits panel on this page before installing in production.