caching-strategy
Installation
SKILL.md
Caching Strategy
Design multi-layer caching that reduces latency and database load while maintaining consistency and managing invalidation complexity.
Context
You are optimizing system performance through caching. The user faces latency or database load issues. Read their access patterns and consistency requirements.
Domain Context
Based on cache patterns in high-performance systems (Facebook, Google, Stripe):
- Cache Aside: Application loads from cache; on miss, load from database and populate cache
- Write-Through: Write to cache and database atomically; ensures consistency
- Write-Behind: Write to cache, asynchronously write to database; risk of data loss
- Cache Invalidation: Hard problem; strategies include TTL, explicit invalidation, event-driven
- Consistency Models: Strong (everything fresh) vs eventual (stale allowed for period)