Agent Native

redis-semantic-cache

This skill guides agents to implement semantic caching for LLM responses using Redis Cloud's LangCache service.

by RedisOfficial publisherNot reviewed

Identity proven by GitHub's verified organisation badge (redis)

Agents
Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
License
MIT (permissive)
Pin
a84871dpinned Oct 9, 2026
Context cost
about 880 tokenswhen the skill loads
GitHub stars
165on redis/agent-skills
Scripts
None found

What 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 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.”
The author's description, from SKILL.md

Generated summary from the skill's own text

This skill guides agents to implement semantic caching for LLM responses using Redis Cloud's LangCache service. It stores prompts as embeddings and returns cached responses for semantically similar queries, reducing API calls and latency. The skill covers cache-aside patterns, similarity threshold tuning, and multi-cache strategies for different task types.

When to use it

  • Reducing LLM API costs and response latency with caching
  • Caching RAG answers, classification outputs, or deterministic LLM workloads
  • Fine-tuning cache hit rates versus precision for specific use cases
  • Isolating different LLM task types into separate cache instances

When not to

  • Non-deterministic LLM outputs or streaming responses
  • When semantic similarity is not applicable to your domain
  • Real-time, time-sensitive queries requiring always-fresh answers

Install

These commands install from the publisher's repository and need no account.

skills CLI

npx skills add redis/agent-skills --skill redis-semantic-cache

Installs from the repository's default branch, which may have changed since the commit we checked.

GitHub CLI 2.90 or later

gh skill install redis/agent-skills redis-semantic-cache@a84871d065f398fed55e1633f66b66f731eb4e2b

Installs the commit we checked (a84871d).

Copy by hand

Download the folder at a84871d and put it in .claude/skills/redis-semantic-cache for Claude Code and in .agents/skills/redis-semantic-cache for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.

Skill folder on GitHub at a84871d

Claude Code plugin

/plugin install redis-development@claude-plugins-official

The publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.

Copy for your agent

A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.

Prompt

Install the agent skill "redis-semantic-cache" by Redis.

Source, pinned to commit a84871d065f398fed55e1633f66b66f731eb4e2b:
https://github.com/redis/agent-skills/tree/a84871d065f398fed55e1633f66b66f731eb4e2b/plugins/redis-development/skills/redis-semantic-cache

1. Download that folder at exactly this commit. Do not use the default branch.
2. Copy every file unchanged, keeping the folder structure, into .claude/skills/redis-semantic-cache/ for Claude Code and .agents/skills/redis-semantic-cache/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist.
3. Do not edit the files, and do not run any script in the folder unless I ask you to.
4. When you are done, list the files you copied and where you put them.

Listing and checks: https://www.agentnative.dev/skills/redis/redis-semantic-cache

SKILL.md at the pin

---
name: redis-semantic-cache
description: 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.
license: MIT
metadata:
  author: Redis, Inc.
  version: "0.1.0"
---

# 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.

```python
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](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 |

```python
# 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](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.

```python
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

- [LangCache documentation](https://redis.io/docs/latest/develop/ai/langcache/)

From redis/agent-skills at a84871d, shown as plain text under its license: MIT (permissive). The license text is in plugins/redis-development/skills/redis-semantic-cache/SKILL.md.

View SKILL.md on GitHub at a84871d

Files

3 files, 8.0 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.

Skill folder on GitHub at a84871d

Also in

The same SKILL.md content appears in these places too. We list it once and credit the oldest public source.

All 8 skills from Redis

More from Redis

  • iris-development

    This skill integrates with Redis Agent Memory, a managed service on Redis Cloud that provides persistent memory for AI agents.

    Claude Code, Codex, Cursor +4 · about 970 tokens · pinned 6 days ago

  • redis-clustering

    This skill guides agents on designing Redis Cluster keys using hash tags to avoid CROSSSLOT errors in multi-key operations, and on routing reads to replicas…

    Claude Code, Codex, Cursor +4 · about 910 tokens · pinned 6 days ago

  • redis-connections

    This skill guides agents on configuring Redis clients efficiently through connection pooling or multiplexing, command pipelining, and proper timeout settings.

    Claude Code, Codex, Cursor +4 · about 1.1K tokens · pinned 6 days ago

  • redis-core

    This skill guides agents in designing Redis data models by selecting appropriate data structures (String, Hash, List, Set, Sorted Set, JSON, Stream, Vector…

    Claude Code, Codex, Cursor +4 · about 640 tokens · pinned 6 days ago

  • redis-observability

    This skill guides agents on monitoring Redis instances by identifying key metrics to track, using built-in diagnostic commands like SLOWLOG and MEMORY DOCTOR…

    Claude Code, Codex, Cursor +4 · about 770 tokens · pinned 6 days ago

  • redis-search

    This skill guides agents through Redis Search for building and querying search indexes on Hash or JSON documents.

    Claude Code, Codex, Cursor +4 · about 2.7K tokens · pinned 6 days ago

All AI and agents skills
  • llm-to-bedrock

    This skill migrates code from OpenAI, Gemini, or Anthropic APIs to Amazon Bedrock by assessing the codebase, rewriting SDK calls, and evaluating output quality.

    by Amazon (AWS)Official publisher

    Contains scripts

    Claude Code · about 15.6K tokens · pinned 6 days ago

  • neon-ai-gateway

    The Neon AI Gateway provides a single API endpoint and credential to access frontier and open-source LLMs from multiple providers (OpenAI, Anthropic, Google…

    by NeonOfficial publisher

    Claude Code, Codex, Cursor +4 · about 4.9K tokens · pinned 6 days ago

  • netlify-ai-gateway

    Calls OpenAI, Anthropic Claude, Google Gemini, TypeSafe, or OpenRouter-hosted models from Netlify Functions and Edge Functions using each provider's official…

    by NetlifyOfficial publisher

    Claude Code, Codex, Cursor +4 · about 3.3K tokens · pinned 6 days ago

  • llm-to-bedrock

    This skill migrates code from OpenAI, Gemini, or Anthropic APIs to Amazon Bedrock by delegating code assessment to the gcp-to-aws skill, then rewriting SDK…

    by Amazon (AWS)Official publisher

    Contains scripts

    Claude Code · about 11.5K tokens · pinned 6 days ago

  • llm-to-bedrock

    Migrates code from OpenAI, Gemini, or Anthropic to Amazon Bedrock by assessing the codebase via the gcp-to-aws skill, then rewriting SDK calls and validating…

    by Amazon (AWS)Official publisher

    Contains scripts

    Claude Code · about 10.7K tokens · pinned 6 days ago

  • anthropic-administrator-automation

    This skill automates Anthropic Admin tasks by connecting to Composio's Anthropic Admin toolkit through Rube MCP.

    by ComposioOfficial publisher

    Agents not labelled yet · about 730 tokens · pinned 6 days ago

The skills listed here are third-party software, collected from public GitHub repositories as a catalog of recent skills and provided as is. Agent Native does not write or control them and is not responsible for any harm, loss or damage caused by installing or using them. Labels and checks describe what we saw at one commit and are not a guarantee. Read a skill's files before you run it. Terms of use