Redis‑style data store focused on network programming, data structures, and low‑level systems code. It implements a TCP server and client and an in‑memory key/value engine (strings and sorted sets). It also includes a binary protocol, timers for key expiration, and a thread pool for background deletes.
# Clone
git clone https://github.com/cmunoz-g/mini-redis.git
cd mini-redis
# Build
make
# Run server
./mini-redis <port>
# Run client
./mini-redis-client <port>Supported commands:
set <key> <value>get <key>del <key>keyszadd <key> <score> <member>zrem <key> <member>zscore <key> <member>zquery <key> <score> <name> <offset> <limit>expire <key> <ttl_ms>quit/exit
- Server loop: builds
pollfdset, computes timer deadline, accepts new connections, processes readable/writable sockets, applies expirations. - Connections: each
Conntracks readiness flags, in/out buffers, and idle/read/write timestamps. Buffers support append/consume. - Request path:
handle_readassembles frames;handle_requestparses length‑prefixed payloads, validates command/arity, dispatchesdo_request. Replies are serialized (response_begin/end). - Protocol: outer frame: 32‑bit big‑endian length. Payload: tag + type‑specific body (
nil/str/int/dbl/arr/err/close). - Database: intrusive key storage via
Entrynodes; strings stored inline, ZSET backed by an AVL tree. - TTL: Expirations are processed in the event loop.
- Thread pool: workers block on a condition variable, pop tasks and execute. Used to background delete entries to speed up performance.
- Protocol format is custom and not Redis RESP.
- Command interface is intentionally minimal, building a full Redis command set is not the scope of this project.