A fast, embedded key-value store in Rust
TurboKV is an async embedded key-value database with atomic batches, ordered
range scans, configurable durability, compression, and background compaction.
TurboKV’s persisted Bloom-filter format uses hardware AES. Build x86/x86_64
targets withRUSTFLAGS=”-C target-feature=+aes,+sse2″, and ARM/AArch64
targets withRUSTFLAGS=”-C target-feature=+aes,+neon”. You may instead use-C target-cpu=nativewhen the binary will run only on the same CPU model or a
feature superset.
One openDborEngineexclusively owns its data directory. Useclose()orclose_with_status()for a clean shutdown; dropping a handle is not a clean
shutdown contract.
Keys and values are arbitrary byte sequences supplied throughAsRef;
strings need to be encoded by the caller. Mutation APIs copy their inputs before
returning. Point and collecting reads return ownedVecvalues. An empty
value is valid data and is distinct from a deleted key.
All presets start with a 64 MiB memtable, a 64 MiB block cache, and LZ4
compression. Their public fields can be adjusted before opening:
With the WAL enabled, one record or complete batch must fit in the WAL’su32payload length. A failed or cancelled mutation may already have reached
the WAL; inspect the key or reopen before retrying a non-idempotent operation.
WriteBatchowns copies of every key and value:
Keys are ordered lexicographically by raw bytes. Every scan captures a coherent
point-in-time view. Creating one can freeze a nonempty active memtable, so
frequent small scans may increase later flush work.
Advancing a streaming iterator is synchronous and may perform mmap reads,
checksum validation, decompression, and cache locking. Drop it promptly: the
iterator pins its snapshot readers and database-directory ownership.
Most database methods returnDbError. Streaming iterator creation returnsDbError, while failures discovered later are yielded asScanError. The
lower-levelEngineand component configuration types are supported advanced
APIs; their complete field and method contracts are in thecrate documentation.
The benchmark used TurboKV 0.6.0, fjall 2.11.2, and redb 2.6.3 over three
repetitions. Throughput is acknowledged keys per second; higher is better.