How cukowski/redis-server works
This is a lightweight Redis-compatible in-memory server: clients send RESP commands over TCP, the server handles clients concurrently, and command processing reads or mutates shared string, list, and hash stores. The database also handles lazy expiration and text-based snapshot persistence. The README documents the broader supported command set; sampled excerpts show the server dispatch, representative command handlers, database operations, and persistence calls, but do not expose every handler implementation.
Main entry points: RedisDatabase.cpp Shared database · RedisCommandHandler.cpp Command router · RedisServer.cpp Socket server · main.cpp Startup entry
Components 15
TCP server
- Socket server
src/RedisServer.cpp
Command processing
- Command handler
src/RedisCommandHandler.cpp - RESP parser
src/RedisCommandHandler.cpp - Command router
src/RedisCommandHandler.cpp
Data operations
- Common commands
src/RedisCommandHandler.cpp - Key-value commands
src/RedisCommandHandler.cpp - List commands
src/RedisCommandHandler.cpp - Hash commands
src/RedisCommandHandler.cpp - Shared database
src/RedisDatabase.cpp - Expiration handling
src/RedisDatabase.cpp
Runtime and persistence
- Snapshot persistence
src/RedisDatabase.cpp - Startup entry
src/main.cpp - Periodic dump
src/main.cpp
Other components
- RESP client
- dump.my_rdb
Connections 20
- RESP client → Socket server: sends commands
README.md - Socket server → Command handler: processes requests
src/RedisServer.cpp - Command handler → RESP parser: parses RESP
src/RedisCommandHandler.cpp - Command handler → Command router: routes commands
src/RedisCommandHandler.cpp - Command router → Common commands: dispatches common
src/RedisCommandHandler.cpp - Command router → Key-value commands: dispatches keys
src/RedisCommandHandler.cpp - Command router → List commands: dispatches lists
src/RedisCommandHandler.cpp - Command router → Hash commands: dispatches hashes
src/RedisCommandHandler.cpp - Common commands → Shared database: clears data
src/RedisCommandHandler.cpp - Key-value commands → Shared database: accesses keys
src/RedisCommandHandler.cpp - List commands → Shared database: accesses lists
src/RedisCommandHandler.cpp - Hash commands → Shared database: accesses hashes
src/RedisCommandHandler.cpp - Shared database → Expiration handling: purges expired
src/RedisDatabase.cpp - Startup entry → Shared database: loads snapshot
src/main.cpp - Startup entry → Socket server: runs server
src/main.cpp - Startup entry → Periodic dump: starts thread
src/main.cpp - Periodic dump → Shared database: dumps periodically
src/main.cpp - Socket server → Shared database: dumps on shutdown
src/RedisServer.cpp - Shared database → Snapshot persistence: serializes state
src/RedisDatabase.cpp - Snapshot persistence → dump.my_rdb: writes or loads
src/RedisDatabase.cpp