NotesSystem

Redis

Also: Valkey

An in-memory data-structure server (strings, hashes, lists, sets, sorted sets, streams) that runs commands on a single main thread. It's the most common shared cache tier, and it's also used as a queue, rate limiter and lock service.

Also in: Caching › In the real world

Design choices

  • Caching: in-memory, with optional persistence (RDB snapshots, AOF log) and replication. Caches usually run it with persistence relaxed.
  • Cache Eviction Policy: maxmemory-policy picks allkeys- or volatile- LRU, LFU, random, LRM (least recently modified, since 8.6), or volatile-ttl. All are approximated by sampling (5 keys by default, fed into a pool of candidates), and LFU uses a decaying probabilistic counter. The default is noeviction, which rejects writes when full.
  • Cache Invalidation: per-key TTLs, plus server-assisted client-side caching ("tracking") that pushes invalidation messages to clients holding local copies.
  • Licensing: moved to source-available licences in March 2024. The Linux Foundation's BSD-licensed Valkey fork followed days later, and Redis 8 added AGPLv3 as an option in 2025.

Notable trade-offs

  • The single-threaded command model makes each command atomic, but one slow command (a huge KEYS or DEL) stalls everyone.
  • Rich data structures invite using it as a database. Persistence and failover are weaker than a real database's.