caching-strategy

Design multi-layer caching strategies with TTLs, invalidation patterns, and Redis implementations.

1|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts --skill caching-strategy-kalilurrahman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: caching-strategy
Source: https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts/tree/main/01-software-dev/caching-strategy
Command: npx skills add https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts --skill caching-strategy-kalilurrahman

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Slow database queries and high infrastructure costs often stem from repeatedly fetching the same data. This Skill designs a complete caching architecture—choosing cache layers, setting TTLs, planning invalidation, and estimating cost savings—so you reduce database load without serving stale data. ## Core Features & Use Cases - Multi-Layer Cache Design: Plans browser, CDN, application (Redis/Memcached), and database query cache layers with per-layer TTLs and size limits. - Cache Patterns & Invalidation: Implements cache-aside, read-through, write-through, and write-behind patterns plus event-based, tag-based, and stampede-protection invalidation. - Monitoring & Sizing: Provides hit rate, eviction, and memory metrics with Prometheus queries, plus memory sizing and ROI estimates. - Use Case: For an e-commerce app with 90% reads, generate a strategy caching product catalogs in Redis with 1-hour TTLs, homepage HTML at the CDN, and session tokens for 24 hours—cutting database queries by 70%. ## Quick Start Design a caching strategy for a read-heavy product catalog application that can tolerate up to one minute of data staleness.

Frequently Asked Questions about caching-strategy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design a caching strategy with Redis?

Identify read-heavy data with tolerable staleness, then apply the cache-aside pattern: check Redis first, query the database on miss, and store results with a TTL. Set TTLs by data type, such as 5 minutes for user profiles and 1 hour for product catalogs.

What TTL should I set for cached data?

TTL depends on freshness requirements: 30 seconds for search results, 5 minutes for user profiles, 1 hour for product catalogs, and 24 hours for session tokens. Avoid infinite TTLs since they guarantee eventually stale data.

Cache-aside vs write-through caching, which should I use?

Cache-aside loads data into cache only on demand, keeping memory efficient but making first requests slow. Write-through updates cache synchronously on every write, keeping cache fresh at the cost of higher write latency.

How do I prevent cache stampede when keys expire?

Use a distributed lock so only one request rebuilds the cache while others wait and retry. In Redis, acquire a lock with SET NX EX before querying the database, then release it after repopulating the key.

What data should not be cached?

Avoid caching data requiring real-time accuracy like financial transactions, high-write-frequency data like inventory counts, and sensitive data like passwords or credit cards. High-write workloads above 50% writes may make caching counterproductive.

Why is my cache hit rate low?

A hit rate below 70% usually means you are caching the wrong data or TTLs are too short. Focus on hot data where 20% of keys serve 80% of requests, and lengthen TTLs for frequently accessed keys.