What it is
A key-value storage engine written from scratch in C++20, following the Bitcask design. I built it to really learn low-level systems work: disk I/O, memory and concurrency.
How it works
Every write is appended to the end of a data file, so there are no random seeks. An in-memory hash index (the KeyDir) maps each key to its byte offset, so every read is a single direct seek. Deletes write a tombstone, and COMPACT rewrites only the live records into a fresh file.
Highlights
- Crash recovery: on startup the log is scanned once and the index is rebuilt in milliseconds.
- Checked records: each record starts with a 21-byte header holding a CRC32, a timestamp, the key and value sizes and a tombstone flag.
- Many readers, one writer:
std::shared_mutexand file locks let concurrent readers run alongside atomic writes. - Small but complete: JSON config, a thread-safe logger, and an interactive shell with
SET,GET,DEL,CONTAINSandCOMPACT.
Build it
CMake 3.20+ and a C++20 compiler: cmake -B build && cmake --build build, then run ./build/app.