Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Designs multi-tier database caching with Redis, in-memory and CDN layers, covering cache-aside patterns, TTLs and invalidation.
Use this skill ↓45% 68%+23 ptsof test cases passed
Passed 15 of 22 test cases with the skill, and 10 of 22 without it.
An e-commerce product detail endpoint joins the `products`, `categories`, and `reviews_summary` tables in MySQL. The team wants to cache this data. What object structure, TTL, and invalidation rules should be applied when caching product catalog detail pages?
assigns product detail cache keys a TTL between 5 and 15 minutes
3 of 3 safety checks passed
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 debuggingProfile database queries to identify caching candidates. Focus on queries that: execute more than 100 times per minute, take longer than 50ms, return data that changes less frequently than every 5 minutes, and produce results smaller than 1MB. Use pg_stat_statements or MySQL slow query log.
Design the cache key schema with a consistent naming convention: 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.
Implement the cache-aside pattern for read-heavy data:
GET app:user:12345:profileSET app:user:12345:profile <json> EX 3600DEL app:user:12345:profile to invalidateConfigure TTL values based on data change frequency:
Implement cache stampede prevention for high-traffic cache keys:
TTL * 0.8 with probability 1 / concurrent_requestsSET key:lock NX EX 5 to let one request refresh while others serve stale dataAdd application-level L1 cache using an in-memory LRU cache (Node.js: lru-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).
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.