RocksDict provides a Python binding for RocksDB, offering an efficient on-disk key-value storage solution. It enables users to store, query, and delete a large number of key-value pairs that may not fit into RAM. The library supports storing various Python objects (with Pickle) in its default mode and raw bytes in its raw mode. It also functions as an interface to inspect RocksDB databases created by other languages. The current version is 0.3.29, with a release cadence that includes frequent updates for Python version support and new features.
pip install rocksdictVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a RocksDict, store various data types, retrieve values, close and reopen the database, iterate through its contents, and finally clean up by destroying the database.
Remove calls to these deprecated `Options` methods. Consult RocksDB documentation for alternative configurations if needed.
Be aware of the mode when interacting with externally created databases. If non-byte Python objects are expected, ensure your application handles serialization/deserialization or re-evaluate the use of Raw Mode.
Avoid relying on RocksDB's merge operators or custom comparators when using `rocksdict`. Implement read-modify-write patterns at the application level if merge-like behavior is required, acknowledging potential performance implications and concurrency challenges.
Always call `db.close()` before attempting operations like `db.repair(path)`. Ensure robust error handling and proper shutdown procedures in your application to minimize the risk of corruption. Consider using transactions or backups for critical data.
pip install rocksdict
Ensure no other process is using the database, or explicitly close previous connections if they weren't shut down cleanly. If a process crashed, you might need to manually delete the 'LOCK' file within the database directory.
Convert the key to a string or bytes before using it (e.g., `str(your_key)` or `your_key.encode('utf-8')`).Use `db.put(key, value)` instead of `db.set(key, value)` to store data in the RocksDict instance.
No dependency data recorded yet.