Storage backends

Storage backends #

--storage-backend <name> selects the driver that sits under the ledis data model. The command layer is written against store.driver.IDB, so the same commands run on every backend — what changes is where the bytes live, who replicates them, and how much you can trust the driver.

type IDB interface {
    Close() error
    Get(key []byte) ([]byte, error)
    Put(key []byte, value []byte) error
    Delete(key []byte) error
    SyncPut(key []byte, value []byte) error
    SyncDelete(key []byte) error
    NewIterator() IIterator
    NewWriteBatch() IWriteBatch
    NewSnapshot() (ISnapshot, error)
    Compact() error
    GetStorageEngine() interface{}
}

What each backend is #

--storage-backendWhere data livesReplicationExternal dependency
goleveldb (default)Local LevelDB (pure Go)Raft only—
badgerLocal BadgerDB v4, ZSTD compressionRaft only—
hybriddbLocal LevelDB + Ristretto hot cache, per-driver metricsRaft only—
ossS3-compatible object store, local LevelDB index + Ristretto cacheRaft onlyS3/MinIO endpoint
ipfsLocal LevelDB whose values are fetched from IPFS by CIDRaft onlyIPFS API (not a gateway)
ipfs-synckvIPFS as source of truth + local mirror + version metadata, optional AES-256IPFS/ipfs-log P2PIPFS API + P2P
crdtLocal Badger + icefiredb-crdt-kv over libp2p pubsubP2P CRDTlibp2p peers
ipfs-logAppend-only icefiredb-ipfs-log store over IPFS pubsubP2P logIPFS + P2P

leveldb (the cgo driver) and orbitdb are not compiled into the binary: the former is never imported, the latter is commented out in main.go/flags.go. Passing either name fails at startup with “unknown driver”.

Choosing one #

  • Default / most workloads — goleveldb. Pure Go, no cgo, predictable memory, no external services.
  • Write-heavy local workloads — badger. Note the driver opens with large fixed defaults (1 GB memtable, 1 GB block cache, 100 goroutines/compactors), so size the host accordingly.
  • Read-heavy working sets that fit in RAM — hybriddb. The hot tier absorbs reads, and the driver registers read_operations, write_operations, bytes_read, errors … into INFO.
  • Data that must outlive the host — oss, with --oss-endpoint, --oss-ak, --oss-sk. Every write goes to the object store and a local LevelDB index keeps it addressable; keep the local disk because it carries the index.
  • Multi-site / decentralized — ipfs-synckv or crdt. Both replicate through libp2p pubsub and are configured with --servicename, --nettopic, --datatopic (all three must match across nodes).
  • Not as a general backend today — ipfs. Its write path stores the raw value locally while the read path treats the stored bytes as an IPFS CID and cats them, so a value written through the engine does not round-trip. Use ipfs-synckv when you want IPFS persistence.

Per-backend configuration #

BackendFlagsDefaults
ipfs, ipfs-synckv--ipfs-endpointhttp://localhost:5001 (the API port, not the 8080 gateway)
ipfs-synckv--ipfs-synckv-keyempty → no encryption; a 32-byte key enables AES-256
ipfs-log--ipfs-log-dbname, or env IPFS_LOG_DBNAMEifdb-event-kv-ipfs-log
oss--oss-endpoint, --oss-ak, --oss-skhttp://localhost:9000 + placeholder credentials
crdt, ipfs-log--servicename, --nettopic, --datatopicicefiredb, icefiredb-net, icefiredb-data

The hot-cache capacity of oss, ipfs and ipfs-synckv is not configurable from the command line: it is the driver constant of 1024 MB. See Configuration.

Guarantees you do and do not get #

You get

  • The same command semantics on every backend, including the per-type keyspaces and per-type expiry.
  • Raft snapshot/restore that is backend-agnostic: writeSnapshot iterates the driver’s snapshot and streams key/value pairs in sds format inside a gzip file, so a backup taken on badger can be restored into a fresh goleveldb node (see Operations).
  • Backend metrics in INFO for hybriddb, ipfs, ipfs-synckv, oss.

You do not get

  • No cross-backend on-disk compatibility. Do not change --storage-backend for an existing data directory; the formats are unrelated.
  • No “empty value” distinction on the decentralized drivers. They collapse “missing” and “empty”, so an empty string reads back as a nil reply. Pinned in Compatibility.
  • No driver-level retry or repair. A failed write surfaces as a command error; on a P2P driver a temporarily unreachable peer shows up as missing data until the log catches up.

Test coverage, by driver #

DriverTestsNotes
goleveldbengine-level compat suite (DRIVER=goleveldb make test-compat)via ledisdb
badgerdriver/badger/db_test.go + engine suite (default DRIVER=badger)—
hybriddbdriver/hybriddb/{db,iterator,snapshot,write_batch}_test.go—
ipfs-synckvdriver/ipfs-synckv/{db,iterator,singularity}_test.goneeds an IPFS daemon
ossdriver/oss/s3_test.goneeds S3/MinIO (CI runs localstack)
ipfs, crdt, ipfs-logno unit tests in this repositoryexercised manually against real peers

That table is the honest version of “supported”: a driver with no test can still work, but nothing in CI will tell you when it stops working.