caching-strategies
Installation
SKILL.md
Backend Caching Strategies
Optimize performance with Redis caching patterns and smart invalidation.
Pattern Selection
| Pattern | Write | Read | Consistency | Use Case |
|---|---|---|---|---|
| Cache-Aside | DB first | Cache → DB | Eventual | General purpose |
| Write-Through | Cache + DB | Cache | Strong | Critical data |
| Write-Behind | Cache, async DB | Cache | Eventual | High write load |
| Read-Through | Cache handles | Cache → DB | Eventual | Simplified reads |
Cache-Aside (Lazy Loading)
import redis.asyncio as redis
from typing import TypeVar, Callable
import json