An embedded Redis-protocol server backed by dkv (this repo's embedded KV store), using a master/sub-reactor design:
- Master reactor:
epollonly foraccept(), then dispatches connection fds to sub-reactors. - Sub-reactors: one
epollper thread, handles socket I/O + RESP parsing + task dispatch. - Worker pool: runs
dkvoperations and posts responses back to the owning sub-reactor.
# from repo root
cmake -S . -B build -DDKV_BUILD_SERVER=ON
cmake --build build -j./build/dkv-server --data-dir ./dkv-data --bind 0.0.0.0 --port 6379 --subreactors 4 --workers 8Quick check with redis-cli:
redis-cli -p 6379 PING
redis-cli -p 6379 SET k v
redis-cli -p 6379 GET kPING [message]ECHO <message>GET <key>SET <key> <value>DEL <key> [key ...]EXISTS <key> [key ...]MGET <key> [key ...]MSET <key> <value> [key value ...]INCR <key>INCRBY <key> <increment>DECR <key>DECRBY <key> <decrement>QUITHELLO(minimal reply)INFO(minimal reply)COMMAND(returns empty array)CLIENT SETINFO ...(accepted; returnsOK)CONFIG GET <pattern>(exposes server + dkv config, e.g.CONFIG GET *,CONFIG GET data-dir)CONFIG RESETSTAT,CONFIG REWRITE(returnsOK)METRICS/METRIC(returnsdkv::Metricsas an array of key/value pairs)FLUSH(forcesdb->Flush())COMPACT(forcesdb->Compact())
Unsupported commands return -ERR unknown command.
These commands expose dkv::DB::Iterator over RESP for debugging and admin workflows.
SCAN [prefix]-> returns[iter_id, valid, key, value]SEEKTOFIRST <iter_id>-> returns[valid, key, value]SEEK <iter_id> <target>-> returns[valid, key, value]NEXT <iter_id>-> returns[valid, key, value]VALID <iter_id>-> returns0or1ITERDEL <iter_id>-> closes the iterator (frees memory)
Notes:
- The iterator is a point-in-time view built when
SCANruns (not a live cursor). key/valueare returned as RESP bulk strings; ifvalid=0, both arenil.
All dkv::Options fields are exposed as CLI flags (see include/dkv/options.h).
Notes:
*-bytesoptions accept plain integers (bytes) and alsoK|KB,M|MB,G|GBsuffixes (base 1024).- Boolean options accept
true/false/1/0/yes/no/on/off. Passing the flag without a value meanstrue.
--bind <ip>(default0.0.0.0)--port <port>(default6379)--subreactors <n>(0= auto)--workers <n>(0= auto)
--data-dir <path>--memtable-soft-limit-bytes <bytes>--sync-wal [bool]--sstable-target-size-bytes <bytes>--sstable-block-size-bytes <bytes>--bloom-bits-per-key <n>--bloom-cache-capacity-bytes <bytes>--raw-block-cache-capacity-bytes <bytes>--block-cache-capacity-bytes <bytes>--level0-file-limit <n>--level-base-bytes <bytes>--level-size-multiplier <n>--max-levels <n>--flush-thread-count <n>--max-immutable-memtables <n>--compaction-thread-count <n>--wal-sync-interval-ms <ms>--enable-crc [bool]--verify-sstable-crc [bool]--enable-compress [bool](requiresdkvbuilt with a compression backend)
All persistent files live under --data-dir:
wal.log: active WALwal-*.log: rotated WAL segmentsMANIFEST: manifest filesst/: SSTable files