RocksDB-Sharp
High-performance .NET bindings for Facebook's RocksDB — an embedded, persistent key-value store optimized for flash and RAM.
What is RocksDB-Sharp?
RocksDB-Sharp is a C# binding for Facebook's RocksDB, the embedded key-value store powering Cassandra, Kafka Streams, CockroachDB, and many other large-scale systems. RocksDB itself is a log-structured-merge (LSM) tree database optimised for flash and RAM, and it can be tuned to balance write-, read-, and space-amplification factors.
This library packages the native RocksDB build for Windows, Linux, and macOS together with an idiomatic C# API. The NuGet version tracks the upstream RocksDB release — for example, NuGet 6.7.3.6120 wraps the upstream v6.7.3 release.
Project on GitHub Facebook RocksDB RocksDB Wiki
A first taste
using RocksDbSharp;
var options = new DbOptions().SetCreateIfMissing(true);
using (var db = RocksDb.Open(options, "/tmp/my-db"))
{
db.Put("hello", "world");
string value = db.Get("hello"); // "world"
db.Remove("hello");
}
The same API works with byte[] and ReadOnlySpan<byte> for arbitrary binary payloads.
Why RocksDB-Sharp?
Built for throughput
LSM-tree storage with sequential I/O, configurable compaction, and an embedded design that runs in-process — no network hop, no separate server.
Layered API
Direct access to the C API (Native), light wrappers for marshalling, and a high-level RocksDb class. Drop down a layer whenever you need to.
Cross-platform native
Native binaries for Windows, Linux, and macOS ship inside the NuGet package. Automatically loaded at runtime by the included AutoNativeImport helper.
Full feature surface
Column families, merge operators, write batches, snapshots, checkpoints, SST ingestion, TTL databases, secondary instances, and WAL replication — all exposed.
Pick your path
Core Concepts
How RocksDB stores data, how to open/close databases, and how options flow through the API.
Guides
End-to-end recipes: iterators, write batches, snapshots, column families, merge operators, bulk loading, checkpoints.
Configuration
Tune database, column family, read, and write options — including block-based table options and Bloom filters.
How this binding is structured
RocksDB-Sharp exposes three levels you can mix freely:
| Layer | What it is | When to use it |
|---|---|---|
High level — RocksDb, Iterator, WriteBatch, Snapshot, ColumnFamilies |
Idiomatic C# classes that manage handles for you. | Default for application code. |
Mid level — Native.Wrap / Native.Marshaled |
Wrappers around the C API that handle marshalling and errptr translation. |
When you need a function the high-level API doesn't yet expose. |
Low level — Native |
Direct P/Invoke bindings to the RocksDB C API. | Maximum control, full feature parity with upstream. |
Learn more about RocksDB itself
Most concepts in this library map 1:1 to upstream RocksDB. The official RocksDB Wiki is the canonical reference for the engine, and the pages below are good entry points: