Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Process use when you need to implement multi-tier caching to improve database performance. This skill sets up Redis, in-memory caching, and CDN layers to reduce database load. Trigger with phrases like "implement database caching", "add Redis cache layer", "improve query performance with caching", or "reduce database load".
.claude/skills/jeremylongshore-implementing-database-caching/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | -17% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 15% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 35% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 66% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 56% | 0% |
Implement multi-tier caching strategies using Redis, application-level in-memory caches, and query result caching to reduce database load and improve read latency. This skill covers cache-aside, write-through, and write-behind patterns with proper invalidation strategies, TTL configuration, and cache stampede prevention.
docker run redis:7-alpineredis-cli installed for cache inspection and debuggingpg_stat_statements or MySQL slow query log.service:entity:identifier:variant. Examples: app:user:12345:profile, app:products:category:electronics:page:1. Include a version prefix to enable bulk invalidation: v2:app:user:12345.GET app:user:12345:profileSET app:user:12345:profile <json> EX 3600DEL app:user:12345:profile to invalidateTTL * 0.8 with probability 1 / concurrent_requestsSET key:lock NX EX 5 to let one request refresh while others serve stale datalru-cache, Python: cachetools, Java: Caffeine) for per-process caching of ultra-hot data. Set L1 TTL shorter than Redis TTL (e.g., 60 seconds L1, 5 minutes Redis).maxmemory to 75% of available RAMmaxmemory-policy allkeys-lru for cache workloadssave "" (disable RDB persistence) for pure cache usetcp-keepalive 60 and timeout 300hits / (hits + misses)), cache miss latency (time to populate from DB), Redis memory usage, eviction rate, and average key TTL remaining. Alert when hit rate drops below 80%.| Error | Cause | Solution | |-------|-------|---------| | Redis connection refused | Redis server down or network issue | Implement circuit breaker pattern; fall through to database on cache unavailability; retry with exponential backoff | | Cache stampede on popular key expiration | Many concurrent requests hit cache miss simultaneously | Use distributed locking or probabilistic early refresh; extend TTL with jitter (TTL + random(0, TTL*0.1)) | | Stale data served after database update | Cache invalidation missed or delayed | Audit invalidation paths; use publish/subscribe for cache invalidation events; reduce TTL for sensitive data | | Redis out of memory (OOM) | Cache size exceeds maxmemory setting | Enable allkeys-lru eviction; reduce TTLs; audit large keys with redis-cli --bigkeys; increase maxmemory | | Cache key collision | Different data stored under the same key pattern | Include all discriminating parameters in the cache key; add content hash to key for variant detection |
Caching product catalog for an e-commerce site: Product detail pages query 3 tables (products, categories, reviews_summary). Cache the assembled product JSON in Redis with TTL of 10 minutes. Cache hit rate reaches 95% since products change rarely. Category pages use list cache keys app:products:category:electronics:sort:price:page:1 with 5-minute TTL. On product update, invalidate both the product key and all category list keys containing that product.
User session caching with Redis: Store session data as Redis hashes (HSET session:abc123 userId 456 role admin lastAccess 1705341234). Set TTL to 30 minutes with sliding expiration on each access (EXPIRE session:abc123 1800). Session reads drop from 2ms (PostgreSQL) to 0.1ms (Redis), eliminating 50,000 database queries per minute.
API response caching with stale-while-revalidate: Dashboard endpoint takes 3 seconds to compute. Cache the response with 5-minute TTL. When TTL expires, the first request triggers an async background refresh while serving the stale cached response. Subsequent requests within the refresh window also receive the stale response. Dashboard always loads in under 5ms from the client perspective.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-06 | fail→fail | 23,949 | 16,318 | -32% | 1 | 1 | 0% | 3,052 | 4,465 | +46% | 0 | 0 | — |
case-01 | fail→pass | 73,290 | 31,769 | -57% | 1 | 1 | 0% | 7,499 | 6,215 | -17% | 0 | 0 | — |
case-02 | fail→pass | 37,610 | 36,447 | -3% | 1 | 1 | 0% | 7,184 | 8,248 | +15% | 0 | 0 | — |
case-03 | fail→fail | 55,933 | 55,311 | -1% | 1 | 1 | 0% | 7,882 | 7,465 | -5% | 0 | 0 | — |
case-04 | fail→pass | 23,084 | 14,709 | -36% | 1 | 1 | 0% | 2,989 | 4,049 | +35% | 0 | 0 | — |
case-05 | pass→pass | 20,312 | 19,377 | -5% | 1 | 1 | 0% | 2,770 | 3,748 | +35% | 0 | 0 | — |
case-07 | pass→pass | 25,483 | 30,793 | +21% | 1 | 1 | 0% | 3,671 | 5,725 | +56% | 0 | 0 | — |
case-08 | pass→fail | 18,564 | 18,409 | -1% | 1 | 1 | 0% | 2,286 | 3,538 | +55% | 0 | 0 | — |
case-09 | fail→fail | 14,324 | 14,684 | +3% | 1 | 1 | 0% | 2,477 | 4,093 | +65% | 0 | 0 | — |
case-10 | fail→fail | 17,784 | 15,132 | -15% | 1 | 1 | 0% | 3,115 | 4,340 | +39% | 0 | 0 | — |
case-11 | fail→pass | 14,104 | 11,101 | -21% | 1 | 1 | 0% | 2,179 | 3,626 | +66% | 0 | 0 | — |
case-12 | fail→pass | 14,823 | 13,902 | -6% | 1 | 1 | 0% | 2,691 | 4,190 | +56% | 0 | 0 | — |
case-13 | pass→pass | 17,061 | 21,510 | +26% | 1 | 1 | 0% | 3,001 | 4,544 | +51% | 0 | 0 | — |
case-14 | fail→fail | 18,317 | 18,192 | -1% | 1 | 1 | 0% | 2,960 | 4,816 | +63% | 0 | 0 | — |
case-15 | pass→pass | 21,312 | 15,718 | -26% | 1 | 1 | 0% | 2,667 | 3,894 | +46% | 0 | 0 | — |
case-16 | fail→pass | 18,663 | 23,944 | +28% | 1 | 1 | 0% | 2,956 | 5,316 | +80% | 0 | 0 | — |
case-17 | pass→pass | 21,837 | 20,715 | -5% | 1 | 1 | 0% | 2,861 | 4,443 | +55% | 0 | 0 | — |
case-18 | fail→fail | 15,431 | 12,945 | -16% | 1 | 1 | 0% | 2,381 | 2,783 | +17% | 0 | 0 | — |
case-19 | pass→pass | 18,405 | 20,474 | +11% | 1 | 1 | 0% | 2,795 | 3,994 | +43% | 0 | 0 | — |
case-20 | pass→pass | 33,980 | 30,571 | -10% | 1 | 1 | 0% | 5,446 | 5,741 | +5% | 0 | 0 | — |
case-21 | pass→pass | 17,972 | 19,647 | +9% | 1 | 1 | 0% | 2,214 | 3,752 | +69% | 0 | 0 | — |
case-22 | pass→pass | 19,847 | 16,132 | -19% | 1 | 1 | 0% | 2,773 | 3,397 | +23% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +23 percentage points is the difference between those two pass rates over the 22 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.