Spill module persists evicted keys to RocksDB, expanding cache capacity onto disk while transparently restoring keys and fully preserving TTLs.
- Automatically persists evicted keys to RocksDB
- Transparently restores keys on cache misses
- Fully preserves TTLs across evictions and restores
- One RocksDB instance per database — keys are isolated per DiceDB databases (db0, db1, …)
FLUSHDBclears only the affected database's spill store;FLUSHALLclears all- Starts fresh on every load — no stale data from previous runs
- Adds minimal overhead with only 12 bytes of metadata per key
- Automatically cleans up expired keys
The quickest and easiest way to see dicedb-spill in action is by using the official Docker image of DiceDB which comes with everything pre-configured.
docker run \
--name dicedb-001 \
-p 6379:6379 -v $(pwd)/data:/data/ \
dicedb/dicedbThis command starts a DiceDB container with the spill module already enabled. By default, the spill module uses RocksDB and is configured with a maximum memory limit of 250MB.
docker run \
--name dicedb-001 \
-p 6379:6379 -v $(pwd)/data:/data/ \
dicedb/dicedb \
dicedb-server \
--port 6379 \
--maxmemory 500mb \
--protected-mode no \
--loadmodule /usr/local/lib/lib-spill.so path /data/spill/ max-memory 262144000Once the DiceDB server is running with spill module loaded,
run the following commands which - sets a key, evicts a key,
and when we try to access it (via GET) it trasparently
loads it in memory.
docker exec -it dicedb-001 dicedb-cliWe are explicitly eviciting the key using EVICT command, but in a production setup
this might happen due to memory pressure
SET k1 v1
EVICT k1
KEYS *
GET k1
This repository is intended to be used as a submodule and must be located at modules/dicedb-spill inside the DiceDB repository and please clone dicedb/dicedb repository with
a --recursive flag and then init the git submodule.
# Basic build (portable, no compression)
$ sudo ./scripts/install_rocksdb.sh
# Build with compression support
$ sudo ENABLE_COMPRESSION=1 ./scripts/install_rocksdb.sh
# Build with native CPU optimizations (SIMD, AVX - higher performance, less portable)
$ sudo PORTABLE=0 ./scripts/install_rocksdb.sh
# Full optimization (compression + native CPU optimizations)
$ sudo ENABLE_COMPRESSION=1 PORTABLE=0 ./scripts/install_rocksdb.shENABLE_COMPRESSION- Enables compression libraries (snappy, zlib, bz2, lz4, zstd)PORTABLE- Builds a cross-CPU compatible version. Set to0to enable native CPU optimizations
# Build without compression
$ make
# Build with compression support (must match the RocksDB build configuration)
$ make ENABLE_COMPRESSION=1Start the DiceDB server with the Spill module loaded:
./src/dicedb-server \
--loadmodule ./modules/dicedb-spill/lib-spill.so \
path /tmp/data max-memory 256 cleanup-interval 300Run the test suite:
make test