caching-strategieslisted
Install: claude install-skill KraitDev/skiLL.Md
# Caching Strategies
## Purpose
Databases are slow; caches are fast. This skill teaches teams to strategically cache frequently accessed data in fast storage (Redis, Memcached) to intercept requests before they hit the database, dramatically reducing latency and database load. Caching is NOT a substitute for proper database optimization.
## When to use
- System is experiencing high latency on read-heavy API endpoints
- Database CPU/Memory usage is constantly peaking due to repeated queries
- Designing a new system expecting massive read throughput
- Content rarely changes but reads happen constantly
## When NOT to use
- Before optimizing database queries (optimize first, cache second)
- For data that changes frequently or is highly personalized
- When consistency is more important than performance
- As a quick fix for poor application architecture
## Inputs required
- Slow query logs or endpoint metrics
- Cache infrastructure (Redis, Memcached)
- Read/write patterns of the data
- Acceptable staleness window (TTL)
## Workflow
1. **Identify Bottlenecks**: Profile APIs to find read-heavy, slow-changing data (user profiles, static config, product catalogs)
2. **Measure Access Patterns**: How often is data read vs. written? How large? How old can it be?
3. **Select Strategy**:
- *Cache-Aside*: App checks cache; on miss, fetches DB, writes cache
- *Write-Through*: App writes to cache and DB simultaneously
- *Write-Behind*: App writes to cache only; batch updates to DB