redis-patternslisted
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