caching

Implements Redis caching patterns including TTL, invalidation, and stampede protection.

Updated Sep 2, 2026
One-click install
npx skills add https://github.com/Dazlarus/karl-code --skill caching-dazlarus
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: caching
Source: https://github.com/Dazlarus/karl-code/tree/main/.agents/skills/caching
Command: npx skills add https://github.com/Dazlarus/karl-code --skill caching-dazlarus

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Applications that repeatedly query databases for the same data suffer from latency and load issues, and poorly designed caches introduce stale data, stampedes, and key collisions. ## Core Features & Use Cases - Cache Patterns: Implements cache-aside, write-through, write-behind, and multi-layer caching with Redis and in-memory layers. - Invalidation & Consistency: Provides tag-based group invalidation, per-data-type TTL strategies, and cache warming for hot data. - Reliability: Prevents cache stampede with Redis-based locking and monitors hit rates for performance tuning. - Use Case: When a user profile endpoint hits the database on every request, apply cache-aside with a one-hour TTL and tag-based invalidation so profile updates clear related entries immediately. ## Quick Start Review my Redis caching layer and add stampede protection plus tag-based invalidation for user profile data.

Frequently Asked Questions about caching

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

FAQPage Schema
How do I implement cache-aside pattern with Redis in Python?▼

Cache-aside checks Redis first, and on a miss fetches from the database then writes the result back with setex and a TTL. This lazy-loading approach keeps the cache populated only with data actually requested.

How to prevent cache stampede in Redis?▼

Use a Redis lock key set with nx=True and an expiry so only one request fetches from the database while others wait and retry. This prevents a thundering herd when a hot key expires.

What TTL should I use for different cached data types?▼

Match TTL to data volatility: rarely changing data like user profiles can use one hour, sessions around fifteen minutes, and frequently changing feeds about one minute. Avoid infinite TTLs.

How do I invalidate related cache entries together in Redis?▼

Use tag-based invalidation: store each key in a Redis set per tag, then delete all keys in the set when that tag is invalidated. This clears groups like user and profile entries in one operation.

When should I not use a caching layer?▼

Skip caching for simple in-memory dictionaries used temporarily, database query optimization problems better handled by profiling, and static assets served with HTTP-level caching. Caching adds complexity that only pays off for repeated expensive reads.