Single-Node Key-Value Core
Build GET, SET, and DEL around one in-memory dictionary while defining clear command, reply, and missing-key semantics.
Guided learning track
Redis-inspired in-memory data store built from key-value command execution through protocol handling, storage internals, persistence, replication, failover, and cluster sharding.
Single-node Core · Tutorial 1 of 24
Build command-owned in-memory key-value behavior before adding protocol or scheduling concerns.
Build GET, SET, and DEL around one in-memory dictionary while defining clear command, reply, and missing-key semantics.
Add byte framing and client connection lifecycle after command semantics are stable.
Parse incremental RESP frames safely across partial reads, nested values, and malformed input before dispatching commands.
Trace each client from accept through buffered reads, command execution, queued replies, and connection teardown.
Introduce the single-threaded reactor and metadata-driven command dispatch.
Multiplex file readiness and timer work in one event loop while keeping handlers short enough to preserve responsiveness.
Drive validation, authorization, and execution from command metadata instead of hard-coding a separate request path for every command.
Explain object representation, dictionary maintenance, and typed payloads one mechanism at a time.
Separate logical value types from physical encodings so representation can change without changing command semantics.
Spread hash-table resizing across ordinary operations so rehashing avoids a single latency spike while lookups consult both tables.
Choose encodings and operations for lists, hashes, sets, and sorted sets according to their access patterns and size.
Separate time-based expiration from memory-pressure eviction.
Combine lazy expiration on access with sampled active cleanup so expired keys disappear without blocking the server.
Enforce maxmemory by selecting victims under an explicit eviction policy whose trade-offs match the workload.
Add queued, atomic, fanout, and log-like command behaviors after core data types exist.
Pipeline requests to reduce round trips while bounding per-client output buffers so slow consumers cannot exhaust memory.
Queue commands between MULTI and EXEC, and use WATCH to abort optimistic transactions when observed keys change.
Execute server-side scripts atomically by blocking interleaving, while controlling runtime so one script cannot stall every client.
Fan published messages out to channel and pattern subscribers while accepting Pub/Sub's transient, at-most-once delivery semantics.
Use ordered stream IDs, pending-entry tracking, acknowledgements, and claiming to divide durable work among consumers.
Persist and rebuild the in-memory database with snapshots and append-only history.
Create point-in-time snapshots with fork and copy-on-write, balancing compact recovery files against snapshot cost and possible data loss.
Use an append-only command log plus background rewrite to trade recovery fidelity against write amplification and file growth.
Restore persisted state by loading an RDB snapshot or replaying AOF commands before accepting client traffic.
Copy state to replicas, resume streams, and promote safely after failure.
Bootstrap a replica from a consistent snapshot, then stream buffered writes so it catches up without losing changes made during transfer.
Resume replication from IDs, offsets, and a bounded backlog when history is available, falling back to full synchronization when it is not.
Use independent monitors, quorum, and epochs to promote one replica without letting competing observers create split-brain.
Split key ownership across nodes and move ownership online.
Partition keys into hash slots and use MOVED redirects so clients can discover which node owns each key.
Move hash slots live with migrating and importing states, ASK redirects, and dual-node coordination that preserves availability.
Compose the learned Redis-like mechanisms without introducing new core concepts.
Integrate protocol parsing, event handling, data structures, persistence, replication, and clustering into one coherent Redis-like system.