redis avatar

Redis Semantic Cache

This wraps Redis Cloud's LangCache preview service so you can cache LLM responses by semantic similarity instead of exact string match. When a prompt comes in, it searches for similar embeddings and returns the cached answer if the cosine distance clears your threshold, skipping the model call entirely. Start at 0.9 for the threshold, crank it to 0.95+ if wrong answers hurt, or drop to 0.8 for looser matching on internal tools. The big gotcha is keeping task types separate. Don't let support queries and code questions share a cache or you'll serve nonsense. Split by cache ID or filter with custom attributes if you need finer isolation within one instance.

skills.sh installs
2K
GitHub stars
175
last updated
Aug 21, 2026

Install

$ npx -y skills add redis/agent-skills --skill redis-semantic-cache --agent claude-code

Installs into .claude/skills of the current project.

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"),
)

Sponsors

Details

Repository
github.com/redis/agent-skills
Categories
Backend & APIs, AI & Agent Building, Cloud & Infrastructure, Databases
First seen
Jul 14, 2026

More from redis/agent-skills

All 8
1cognitedata avatarsetup-flows-authcognitedata/builder-skillsMUST be used when migrating an existing React app to Flows, or when no Flows auth is wired up. Detects classic vs Apps API flow from `app.json` `infra` field, i1.9Kskills.sh installs
2kotlin avatarkotlin-backend-jpa-entity-mappingkotlin/kotlin-agent-skillsModel Kotlin persistence code correctly for Spring Data JPA and Hibernate. Covers entity design, identity and equality, uniqueness constraints, relationships, f1.8Kskills.sh installs
3alirezarezvani avatarsenior-backendalirezarezvani/claude-skillsDesigns and implements backend systems including REST APIs, microservices, database architectures, authentication flows, and security hardening. Use when the us1.7Kskills.sh installs
4alchemyplatform avataralchemy-apialchemyplatform/skillsWire Alchemy into application code (server, backend, dApp, script) using a standard API key. Preferred app-integration path for normal server/backend usage. Cov1.7Kskills.sh installs
5jezweb avatard1-drizzle-schemajezweb/claude-skillsGenerate Drizzle ORM schemas for Cloudflare D1 databases with correct D1-specific patterns. Produces schema files, migration commands, type exports, and DATABAS1.7Kskills.sh installs
6loops-so avatarloops-apiloops-so/skillsUse this skill whenever the user wants to integrate Loops from application code, backend services, webhook handlers, or server-side automation. This includes th1.6Kskills.sh installs