Redis Semantic Cache
RedisOfficialCreated by Redis, Inc.
- Skill
- Tool integration
- Data and AI
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
Redis LangCache provides a semantic caching layer for LLM applications, allowing developers to store and retrieve responses based on prompt similarity. By using embeddings to match incoming queries against previously cached results, applications can avoid redundant model calls. This skill covers the integration of LangCache via SDK or REST API, strategies for tuning similarity thresholds to balance precision and hit rates, and best practices for organizing cache instances by task type or using custom attributes for granular filtering.
What it does
- Implements a cache-aside pattern for LLM completions and RAG workflows.
- Provides methods to search for semantically similar prompts using embedding-based matching.
- Allows configuration of similarity thresholds to control match strictness.
- Supports storage and retrieval of LLM responses via Python SDK or REST API.
- Enables logical separation of caches for different application tasks.
- Supports filtering cached entries using custom metadata attributes.
When to use it
- When you need to reduce LLM API costs and response latency.
- When building a cache-aside layer for deterministic or repetitive LLM workloads.
- When you need to manage different LLM tasks within isolated cache instances.
- When you want to tune the balance between cache hit rates and response accuracy.
Advantages
- Significantly lowers latency by serving cached responses for similar queries.
- Reduces operational costs by minimizing redundant calls to external LLM providers.
- Offers flexible matching through adjustable similarity thresholds.
- Supports granular data management via custom attributes and multiple cache IDs.
Usage examples
- “How do I implement a cache-aside pattern with LangCache in Python?”
- The agent provides a code snippet demonstrating the search-then-generate-then-set flow using the LangCache SDK.
- “How can I improve the precision of my semantic cache?”
- The agent explains how to adjust the similarity_threshold parameter, recommending a higher value for stricter matching.
- “Should I use one cache for all my LLM tasks?”
- The agent advises against sharing a single cache for unrelated tasks and suggests using separate cache IDs or custom attributes for isolation.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/redis/redis-semantic-cache/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip redis-semantic-cache.zip -d .agents/skills
Documentation by Redis, Inc.
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:
Send the user's prompt to LangCache's
search.Cache hit — return the stored response directly.
Cache miss — call the LLM, then
setthe 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
Files
- ATTRIBUTION.mdAdded by AutoGineer903 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md4.0 KiB
- references/best-practices.md1.7 KiB
- references/langcache-usage.md2.1 KiB
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an API key, Needs Python
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Redis, Inc.
- Publisher
- Redis (Official)
- Source
- redis/agent-skills · skills/redis-semantic-cache · commit 74708da
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Also distributed in
- redis/agent-skills
AutoGineer is not affiliated with or endorsed by Redis, Inc. or Redis.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download redis-semantic-cache.zip