Expand description
§RocksDB Storage Backend
This module provides a RocksDB-based implementation of the Database trait.
§Why No Connection Pool?
RocksDB already manages resources internally and does not require an external connection pool. Here’s why:
-
Thread Safety: The
DBobject is thread-safe and designed to be shared across multiple threads. A singleDBinstance can handle concurrent read/write operations safely. -
Internal File Handle Management: RocksDB uses an LRU cache to manage open file handles internally. The
max_open_filesoption controls how many SST files RocksDB keeps open simultaneously. When this limit is reached, RocksDB automatically closes least-recently-used file handles. -
Block Cache: RocksDB maintains its own block cache for frequently accessed data, reducing disk I/O without external caching.
-
File Locking: RocksDB uses file locking to prevent multiple processes from opening the same database. Only one
DBinstance can exist per path per process. -
The
StoreWrapper: The higher-levelStoretype already wraps the database in anArc, allowing it to be cloned and shared efficiently across the application.
§Recommended Usage
// Open the database once
let store = Store::open::<RocksDB>(&config)?;
// Clone and share the store (cheap Arc clone)
let store_clone = store.clone();
// Both handles share the same underlying RocksDB instance§Configuration
Resource limits are configured through RocksDB’s native options in the open
method:
max_open_files: Controls file descriptor usage (default: 256)- Block cache: 128MB LRU cache for frequently accessed blocks
If you need to adjust these settings, modify the Options in RocksDB::open().
Structs§
- RocksDB
- RocksDB database wrapper implementing the
Databasetrait.