cachelisted
Install: claude install-skill arbazkhan971/godmode
# Cache -- Caching Strategy
## Activate When
- User invokes `/godmode:cache`
- User says "add caching", "cache invalidation", "stale data", "cache consistency"
- User says "Redis setup", "Memcached config", "CDN configuration"
- User says "cache stampede", "thundering herd", "hot key"
- When `/godmode:perf` identifies slow queries or high latency
## Workflow
### Step 1: Cache Opportunity Assessment
```
CACHE ASSESSMENT:
Project: <name>
Current Caching: None | CDN only | App-level | Multi-layer
Performance Baseline: P50/P95 latency, Database QPS, Cache hit rate
HOT PATH ANALYSIS: Endpoint, QPS, Latency, Cacheable (Y/N), TTL
IMPACT ESTIMATE: Hit rate, latency reduction, DB load reduction
```
### Step 2: Cache Layer Design
Multi-layer architecture: CDN/Edge -> Application (Redis/Memcached) -> DB Query Cache -> Source of Truth (Database).
**Cache-Aside Pattern (Default):**
- Read: check cache -> HIT: return | MISS: query DB, store in cache with TTL, return
- Write: write to DB, then delete cache key (not update). Next read repopulates.
- Use when: read-heavy (10:1+), brief staleness OK. Start here.
### Step 3: Cache Invalidation Strategies
**TTL-Based:** TTL = max acceptable staleness. Static config: 24h. Product catalog: 10m. Search results: 1m. Real-time pricing: 10s. Always set a TTL.
**Event-Based:** On data change, publish event -> consumer deletes cache keys + purges CDN. Near-real-time, precise.
**Write-Through:** Write to cache AND DB synchronously. Always consis