zkv is a small key-value store written in Zig. It runs as a REPL, keeps data in memory, and persists mutations to an append-only log file.
- Zig
0.16.0
zig build runput <key> <value> store value under key
get <key> print value for key
del <key> delete key
exists <key> print whether key exists
count print number of keys
keys print all keys
dump print all key-value pairs
clear delete all keys
compact rewrite log to current engine state
help show help
exit quit
Keys are single tokens and cannot contain whitespace. Values are stored as the rest of the line, so spaces are allowed:
put greeting hello world
get greeting
zkv writes successful mutations to zkv.log in the current working directory:
put name ashish
del name
clear
On startup, the log is replayed into the in-memory engine before the REPL starts. Reads and non-mutating commands are not written to the log.
Run compact to rewrite the log so it contains only the current engine state. This removes stale put and del entries from earlier sessions.
The log format is intentionally simple for now. It assumes keys do not contain whitespace and values do not contain newlines.
zig build testsrc/engine.zig in-memory key-value engine
src/parser.zig REPL command parser
src/log.zig append-only log and replay
src/repl.zig REPL loop and command execution
src/main.zig application entrypoint