vault — Persistent C11 Key-Value Store
Abstract
Compact persistent key-value store (~605 LOC) with a write-ahead log, snapshots, read-write locks, and an edge-triggered Linux epoll TCP server.
1. Request Flow¶
TCP client (or built-in CLI) -> epoll event loop (EPOLLET + O_NONBLOCK) -> Line protocol: SET / GET / DEL / EXISTS / KEYS -> pthread_rwlock_t (parallel reads, exclusive writes) -> 1024-bucket FNV-1a chained hash table -> Append-only WAL (O_APPEND) + point-in-time snapshots
2. Design Notes¶
-
Non-blocking I/O: uses
epoll_create1with edge-triggered events (EPOLLET) to multiplex concurrent clients in one loop. -
Concurrency:
pthread_rwlock_tallows parallelGET,EXISTS, andKEYSwhile serializing writes. -
Durability: every
SETandDELappends a length-prefixed WAL record for startup replay; snapshots compact state for fast reload.
3. Summary¶
- Size
- ~605 LOC C11, compiled with -Wall -Wextra -Werror
- Limits
- 256 B max key, 64 KB max value, 1024 hash buckets
- Tests
- End-to-end TCP integration test (SET, GET, EXISTS, DEL)