Skip to content
Navigation

Type at least two characters. Search covers page titles, headings, tags and database names.

↑ ↓ to navigateEnter to openEsc to close0 pages
Redis and Valkeybeginner

Redis and Valkey Overview

What Redis is, how single-threaded execution shapes its behaviour, and where Valkey fits after the licence change.

3 min readBeginnerUpdated Edit this page

Redis is an in-memory data structure server. It holds the entire dataset in memory, executes commands from a single thread, and offers optional persistence.

Valkey is a fork of Redis 7.2 created in 2024 after Redis Ltd. changed the licence away from BSD. It is maintained under the Linux Foundation, keeps the BSD licence, and is protocol-compatible. Unless a page says otherwise, everything here applies to both.

Architecture

Single-threaded command execution. Commands are executed one at a time by one thread, which is why every operation is atomic without locks and why latency is so predictable. It is also the central constraint: one slow command blocks every other client.

Modern versions use additional threads for I/O and for background freeing of large objects (lazyfree), but command execution itself remains single-threaded.

Memory-resident dataset. Capacity is bounded by RAM. What happens when memory fills is a policy you configure — see Memory Management.

Optional persistence. RDB snapshots and the append-only file give durability that ranges from none to roughly one second of loss. Redis is not designed to be a system of record, and configuring it as one deserves care. See Persistence.

Best use cases

  • Caching — the canonical use, with TTLs and eviction policies designed for it.
  • Rate limiting and counters — atomic increments with expiry.
  • Session storage, where losing a session on failover is acceptable.
  • Queues and streams — Streams provide consumer groups and acknowledgements. See Streams.
  • Leaderboards and ranked sets — sorted sets do this better than a relational engine.
  • Coordination primitives — with the caveats in Distributed Locks.

When not to use it

  • As a durable system of record. Replication is asynchronous and persistence is configurable to be lossy; both are fine for a cache and wrong for a ledger.
  • For datasets much larger than RAM. Redis is not designed to page to disk.
  • For complex queries. There is no query planner, no joins and no secondary indexes in core Redis — you maintain access paths yourself.

Data model

Keys map to typed values: strings, hashes, lists, sets, sorted sets, streams, bitmaps, HyperLogLogs and geospatial indexes. See Data Structures.

Scaling model

  • Vertically — more RAM, faster CPU. Because execution is single-threaded, single-core speed matters more than core count.
  • Read replicas — asynchronous, so replica reads may be stale.
  • Redis Cluster — 16384 hash slots spread across primaries, each with replicas. Multi-key operations are restricted to keys in the same slot. See Redis Cluster.

Common mistakes