llm-caching
Implement multi-layer LLM caching with exact match, semantic similarity, and provider-side prompt caching. Reduce API costs by 30–70%, cut latency, and improve throughput using Redis, GPTCache, and provider caching APIs.
npx skills add majiayu000/claude-skill-registry --skill llm-caching --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# LLM Caching Cut LLM costs and latency with exact match, semantic, and provider-side caching layers. ## When to Use This Skill Use this skill when: - The same or similar queries are asked repeatedly (FAQ bots, support tools) - LLM API costs are growing and you need immediate savings - Serving high request volumes where repeated queries cause bottlenecks - Implementing prompt caching for long system prompts (Anthropic/OpenAI) - Building offline-capable AI features that need response persistence ## Caching Layers ``` Request → Exact Cache → Semantic Cache → Provider Cache → LLM API ↓ hit ↓ hit ↓ hit instant ~5ms 50-80% cheaper ``` ## Layer 1: Exact Match Cache (Redis) ```python import hashlib import json import redis from openai import OpenAI r = redis.Redis(host="localhost", port=6379, decode_responses=True) client = OpenAI() def build_cache_key(model: str, messages: list, temperature: float) -> str: """Deterministic key from request parameters.""" payload = json.dumps({ "model": model, "messages": messages, "temperature": temperature, }, sort_keys=True) return f"llm:exact:{hashlib.sha256(payload.encode()).hexdigest()}" def cached_completion(model: str, messages: list, temperature:
- When to Use This Skill
- Caching Layers
- Layer 1: Exact Match Cache (Redis)
- Layer 2: Semantic Cache (GPTCache)
- Custom Semantic Cache (Production-Grade)
- Layer 3: Provider-Side Prompt Caching
- Cache Warming
- Cache Metrics
- Redis Configuration for LLM Caching
- Common Issues
- Best Practices
- Related Skills
redis.conf tuning for LLM cache workload maxmemory 8gb maxmemory-policy allkeys-lru # evict least-recently-used when full save "" # disable persistence (cache is ephemeral) appendonly no tcp-keepalive 60
What does the llm-caching skill do?
Implement multi-layer LLM caching with exact match, semantic similarity, and provider-side prompt caching. Reduce API costs by 30–70%, cut latency, and improve throughput using Redis, GPTCache, and provider caching APIs.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill llm-caching --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
