caching

Featured

Caching strategies — invalidation, TTL guidelines, cache keys, cache layers, and when not to cache. Use when implementing or reviewing caching logic.

AI & Automation 4,438 stars 448 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

## WHEN_TO_USE - When implementing a cache layer (in-memory, Redis, CDN) for an API or service. - When choosing TTL values or invalidation strategies for cached data. - When designing cache key schemas to avoid collisions or stale-data bugs. - When reviewing code that reads from or writes to any cache. - When debugging stale data, cache stampedes, or inconsistent responses. - When configuring TanStack Query `staleTime`/`gcTime` for client-side caching. ## INVALIDATION - [P0-MUST] Define an invalidation strategy for every cache. Stale data is worse than no cache. - [P0-MUST] Invalidate caches when the underlying data changes — do not rely solely on TTL expiry. - [P1-SHOULD] Prefer event-driven invalidation (on write/update/delete) over time-based expiry alone. - [P1-SHOULD] Use cache versioning (include a version key) when data schemas change. ## TTL_GUIDELINES - [P1-SHOULD] Set TTLs based on data volatility: static config (hours/days), user profiles (minutes), real-time data (seconds or no cache). - [P1-SHOULD] Use stale-while-revalidate: serve stale data immediately while refreshing in the background. - [P2-MAY] Use shorter TTLs in development and longer TTLs in production. ## CACHE_KEYS - [P0-MUST] Include all query parameters that affect the result in the cache key. - [P1-SHOULD] Use a consistent key format: `<entity>:<id>:<variant>` (e.g., `user:123:profile`, `products:list:page=2`). - [P1-SHOULD] Namespace keys by service or module to prevent collisions. - [P2-MAY...

Details

Author
zebbern
Repository
zebbern/claude-code-guide
Created
1 years ago
Last Updated
yesterday
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category