backend-caching
Use when the user asks about caching, adding a Redis cache in front of a query, cache-aside, write-through, cache invalidation, TTL jitter, cache stampede or…
от j4flmao★ 47 звёзд на GitHub
Установить backend-caching в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Backend Caching
Purpose
Design consistent, production-grade caching layers. Every cache must follow the same conventions for strategy selection, data flow, invalidation, stampede prevention, TTL management, and monitoring.
Agent Protocol
Trigger
Exact user phrases: "cache", "Redis", "Memcached", "CDN", "cache-aside", "read-through", "write-through", "write-behind", "cache invalidation", "TTL", "cache stampede", "thundering herd", "cache warming", "LRU", "LFU", "cache hit ratio", "cache strategy", "design a caching layer", "add caching".
Input Context
- The data being cached (DB query result, computed value, API response, static asset).
- The read/write ratio.
- The consistency requirement (eventual vs strong).
- The hosting topology (single node, clustered, multi-region).
Output Artifact
Caching strategy specs as text. No file unless requested.
Response Format
Layer: {application | distributed | CDN}
Store: {Redis | Memcached | CDN | in-memory}
Strategy: {cache-aside | read-through | write-through | write-behind}
Key format: {namespace}:{entity}:{id}
TTL: {duration}
Invalidation: {manual | TTL-based | event-driven}
Stampede protection: {yes/no — method}
No preamble. No postamble. No explanations. No filler/hedging/transitions.
Completion Criteria
- Cache strategy selected with justification
- Key naming convention defined with namespaces
- TTL set for every cache entry (no infinite TTL unless immutable data)
- Stale data tolerance documented
- Invalidation strategy defined (TTL and/or event-driven)
- Cache stampede prevention in place for high-traffic keys
- Monitoring plan (hit ratio, latency, memory) defined
Architecture Decision Trees
Cache Layer Selection
What is the primary goal?
├── Reduce latency for hot data (<1ms reads)
│ ├── Single-node app? → In-memory cache (LRU map, async cache)
│ └── Multi-node app? → Distributed cache (Redis cluster)
├── Reduce database load
│ ├── Read-heavy workload (>80% reads)?
│ │ ├── Yes → Cache-aside with distributed cache
│ │ └── No → Write-behind or read-through
│ └── Expensive queries (>100ms)?
│ ├── Yes → Cache result with medium TTL
│ └── No → Simple cache-aside is sufficient
├── Serve static/semi-static content globally
│ ├── Global audience? → CDN (CloudFront, Cloudflare, Fastly)
│ └── Regional audience? → CDN or reverse proxy cache
└── Handle API response caching
├── Public data? → CDN + gateway caching
└── User-specific data? → Private cache (Cache-Control: private)
Consistency Model Decision Tree
Can the application tolerate stale data?
├── Yes → Is stale-while-revalidate acceptable?
│ ├── Yes → Cache-aside with background refresh
│ └── No → Cache-aside with short TTL (seconds)
├── No, eventual consistency is fine
│ └── Read-through or write-behind
└── No, strong consistency required
├── Is read volume much higher than write?
│ ├── Yes → Delete-on-write after commit + short TTL (DB and Redis cannot be written atomically)
│ └── No → Read the DB directly; cache only derived, non-critical data
└── Is cache acting as source of truth?
└── Never use cache as primary store
Cache Stampede Prevention
Is there a single hot key that gets many concurrent requests?
├── Yes → Does the key expire and cause thundering herd?
│ ├── Yes → Which prevention method?
│ │ ├── Mutex locking (NX key) → First request loads, others wait
│ │ ├── Probabilistic early expiration → Refresh before expiry
│ │ ├── Stale-while-revalidate → Serve stale, refresh async
│ │ └── Background refresh → Dedicated worker refreshes hot keys
│ └── No → Regular cache-aside is sufficient
└── No → Standard TTL-based caching is fine
Invalidation Strategy Selection
Can the system tolerate stale data for up to TTL duration?
├── Yes → TTL-based invalidation (simplest)
├── No → Are cache and DB in the same transaction boundary?
│ ├── Yes → Delete the key after the DB commit (no cross-store transaction exists)
│ └── No → Event-driven invalidation (CDC/outbox publishes eviction events)
└── Mixed → TTL for most data, event-driven for critical data
Workflow
Step 1: Choose Cache Layer
| Layer | Latency | Durability | Shared | Best For |
|---|---|---|---|---|
| In-memory (local) | ~0.1ms | Lost on restart | Per-instance | Hot data, session, computed values |
| Distributed (Redis) | ~1-5ms | Configurable | All instances | Shared data, counters, rate limits |
| CDN | ~10-50ms | Durable at edge | Global | Static assets, public API responses |
| DB-side (materialized view, buffer pool) | DB latency | DB-backed | All instances | Expensive aggregates (MySQL 8.0 removed its query cache) |
Step 2: Choose Strategy
Cache-aside (lazy loading) — default for most applications:
Read:
1. Check cache (key lookup)
2. Cache hit → return data
3. Cache miss →
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/cache-invalidation.md
- references/cache-monitoring.md
- references/cache-strategies.md
- references/cache-testing.md
- references/caching-advanced.md
- references/caching-fundamentals.md
- references/caching-stampede-prevention.md
- references/cdn-caching.md
- references/merged-backend-caching-strategies.md
- references/redis-patterns.md
FAQ
Что делает скилл backend-caching?
Use when the user asks about caching, adding a Redis cache in front of a query, cache-aside, write-through, cache invalidation, TTL jitter, cache stampede or Memcached. Produces a cache strategy with keys, TTLs, invalidation and code. Not for browser/HTTP caching (use frontend-browser-caching) or distributed locks (use backend-distributed-locking).
Как установить скилл backend-caching?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл backend-caching запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…