How debug-boy/miniredis works
MiniRedis is a lightweight RESP-speaking in-memory key-value server. Its principal workflow is a client request arriving over TCP or Unix sockets, being handled by the server’s event loop, parsed and executed, then returned as a RESP reply. The README also documents idle-connection cleanup, configurable dump policies, and binary persistence. The graph includes the documented optional multithreaded path; excerpts do not establish all its call sites, so those links are marked unverified. Several capability links rely on README descriptions rather than sampled implementation details.
Main entry points: server.cpp Event loop · KvCommandEngine.hpp Command engine · KeyValueDumper.hpp Dump and load · Connection.hpp Connection state
Components 17
Server runtime
- Event loop
server/src/server.cpp - Socket listeners
server/src/server.cpp - Connection state
server/include/Connection.hpp - Idle cleanup
server/src/server.cpp - Signal handling
server/src/server.cpp
Protocol and commands
- RESP parser/wrapper
include/common/Resp.hpp - Command engine
server/include/KvCommandEngine.hpp
Data and persistence
- In-memory KV
server/include/KvCommandEngine.hpp - Dump and load
server/include/KeyValueDumper.hpp - Binary snapshot
Runtime support
- Server configuration
server/include/ServerConfigure.hpp - Config parser
include/common/ConfigureParse.hpp - Epoll wrapper
include/common/EventPool.hpp - Thread pool
include/common/ThreadPool.hpp - Lock-free queue
include/common/LockFreeQueue.hpp
Other components
- CLI client
client/src/client.cpp - Redis client
Connections 22
- Redis client → Socket listeners: sends requests
README.md - CLI client → Socket listeners: connects
- Socket listeners → Event loop: registers events
server/src/server.cpp - Event loop → Epoll wrapper: waits for events
README.md - Event loop → Connection state: dispatches I/O
server/src/server.cpp - Event loop → Idle cleanup: handles timer ticks
server/src/server.cpp - Event loop → Signal handling: handles signal events
server/src/server.cpp - Connection state → RESP parser/wrapper: parses buffered requests
README.md - RESP parser/wrapper → Command engine: produces arguments
README.md - Event loop → Command engine: executes queued commands
README.md - Command engine → In-memory KV: reads and writes
server/include/KvCommandEngine.hpp - Command engine → RESP parser/wrapper: formats replies
server/include/KvCommandEngine.hpp - Event loop → Connection state: queues replies
README.md - Server configuration → Config parser: loads settings
server/include/ServerConfigure.hpp - Event loop → Server configuration: uses runtime settings
README.md - Command engine → Dump and load: requests BGSAVE
server/include/KvCommandEngine.hpp - Dump and load → In-memory KV: serializes and restores
README.md - Dump and load → Binary snapshot: writes and reads
README.md - Event loop → Dump and load: loads startup snapshot
README.md - Event loop → Dump and load: checks dump policies
server/src/server.cpp - Event loop → Thread pool: submits batch work
README.md - Event loop → Lock-free queue: passes pending connections
README.md