Abstract: Spindle is a blazing fast, multithreaded in-memory Key-Value database engineered in Modern C++20 for microsecond latency and lock-free concurrency. It implements a highly optimized Sharded Hash Map, lock-free wait structures, a robust Write-Ahead Log (WAL), and an epoll-based Reactor for unparalleled throughput.
Lock contention is eliminated by sharding the main Hash Map into hundreds of independent segments. Writers only lock the specific shard they modify, allowing multiple threads to read and write simultaneously across different shards.
Readers bypass heavy Mutexes completely. Spindle utilizes advanced atomic primitives and SeqLocks (Sequence Locks) to guarantee read consistency without blocking or acquiring traditional locks.
All mutations are appended to an AOF (Append-Only File) for durability. To prevent I/O blocking, WAL writes are asynchronously batched using a high-throughput MPSC (Multi-Producer Single-Consumer) Ring Buffer.
Spindle uses a modern Event Loop built on Linux epoll (Edge Triggered). With SO_REUSEPORT, incoming TCP connections are distributed automatically across a pool of Reactor threads by the kernel.
Tested locally on an 8-core CPU using 100 concurrent connections with Pipelining (batch=100) and tiny payloads. Designed to measure theoretical max engine throughput.
Spindle uses a simple, human-readable text protocol over TCP. Every command must be terminated with a newline (\n).
Stores a value with the specified key. If the key already exists, it is overwritten. You can optionally provide an expiration time.
Integer: (integer) 1 if successful, or ERR INVALID_FORMAT if the syntax is incorrect.