Redis
Overview
Redis is an in-memory data store used as a cache, session store, message broker, rate limiter, and lightweight database (with optional persistence). Its data structures (strings, hashes, lists, sets, sorted sets, streams) map well to common backend patterns.
Key concepts
- Single-threaded command core — Fast, but long commands block others.
- Eviction policies —
volatile-lru,allkeys-lfu, etc., when memory is full. - Persistence — RDB snapshots vs AOF logs—trade durability vs performance.
- Replication & cluster — High availability topologies.
- Security — ACLs, TLS, never expose open instances to the internet.
Cache-aside pattern
Sample: CLI commands
redis-cli SET session:abc123 '{"user_id":42}' EX 3600
redis-cli GET session:abc123
redis-cli INCR rate:ip:203.0.113.10