← ClaudeAtlas

redis-patternslisted

Redis distributed-cache, rate-limiting, distributed-lock, pub/sub and Streams patterns for production backends. Use when adding a distributed cache (cache-aside/write-through, invalidation, TTL, stampede), rate limiting/throttling, cross-worker coordination, or a durable event queue. Out-of-process — not an in-memory app cache.
SilantevBitcoin/Base-system-Claude · ★ 1 · AI & Automation · score 74
Install: claude install-skill SilantevBitcoin/Base-system-Claude
# Redis Patterns Quick reference for Redis in production backends: distributed cache, rate limiting, distributed locks, and messaging (Pub/Sub vs Streams). ## How It Works Redis is an in-memory data-structure store supporting strings, hashes, lists, sets, sorted sets, streams, and more. Individual Redis commands are atomic on a single instance; multi-step workflows need Lua scripts, MULTI/EXEC transactions, or explicit synchronization to stay atomic. Data is optionally persisted via RDB snapshots or AOF logs. Clients communicate over TCP using the RESP protocol; connection pools are essential to avoid per-request handshake overhead. > Lua scripts below run server-side via `EVAL`/`register_script` — that is Redis-native scripting, not client-side `eval` of untrusted input. It is the standard way to make a multi-step operation atomic. ## When to Activate - Adding a distributed cache shared across processes/instances - Implementing rate limiting or throttling - Building distributed locks or cross-worker coordination - Setting up session or token storage - Using Pub/Sub or Redis Streams for messaging - Configuring Redis in production (pooling, eviction, clustering, HA) ## Data Structure Cheat Sheet | Use Case | Structure | Example Key | |----------|-----------|-------------| | Simple cache | String | `product:123` | | User session | Hash | `session:abc` | | Leaderboard | Sorted Set | `scores:weekly` | | Unique visitors | Set | `visitors:2024-01-01` | | Activity feed | Lis