pub struct AsyncRocksDB { /* private fields */ }Expand description
Async-aware wrapper for RocksDB.
Provides non-blocking operations suitable for use in Tokio-based applications.
All operations are executed via tokio::task::spawn_blocking to avoid blocking the async runtime.
Implementations§
Source§impl AsyncRocksDB
impl AsyncRocksDB
Sourcepub async fn open_default<P: AsRef<Path>>(
path: P,
) -> Result<Self, AsyncRocksError>
pub async fn open_default<P: AsRef<Path>>( path: P, ) -> Result<Self, AsyncRocksError>
Opens a database with default options at the given path.
Equivalent to AsyncRocksBuilder::new().open(path).
Sourcepub async fn put<K, V>(
&self,
key: K,
value: V,
cf: Option<&str>,
) -> Result<(), AsyncRocksError>
pub async fn put<K, V>( &self, key: K, value: V, cf: Option<&str>, ) -> Result<(), AsyncRocksError>
Inserts a key-value pair into the database.
cf specifies the column family. Use None for the default column family.
Sourcepub async fn get<K>(
&self,
key: K,
cf: Option<&str>,
snapshot: Option<Snapshot>,
) -> Result<Option<Vec<u8>>, AsyncRocksError>
pub async fn get<K>( &self, key: K, cf: Option<&str>, snapshot: Option<Snapshot>, ) -> Result<Option<Vec<u8>>, AsyncRocksError>
Retrieves a value by key.
Returns None if the key does not exist.
Use snapshot for reading from a point-in-time view.
Sourcepub async fn delete<K>(
&self,
key: K,
cf: Option<&str>,
) -> Result<(), AsyncRocksError>
pub async fn delete<K>( &self, key: K, cf: Option<&str>, ) -> Result<(), AsyncRocksError>
Deletes a key from the database.
Sourcepub async fn multi_get<K>(
&self,
keys: Vec<K>,
cf: Option<&str>,
snapshot: Option<Snapshot>,
) -> Result<Vec<Option<Vec<u8>>>, AsyncRocksError>
pub async fn multi_get<K>( &self, keys: Vec<K>, cf: Option<&str>, snapshot: Option<Snapshot>, ) -> Result<Vec<Option<Vec<u8>>>, AsyncRocksError>
Retrieves multiple values by keys in a single operation.
Returns a Vec with the same length as keys, containing Some(value) or None.
Sourcepub async fn multi_delete<K>(
&self,
keys: Vec<K>,
cf: Option<&str>,
) -> Result<(), AsyncRocksError>
pub async fn multi_delete<K>( &self, keys: Vec<K>, cf: Option<&str>, ) -> Result<(), AsyncRocksError>
Deletes multiple keys in a single operation.
Sourcepub async fn flush(&self) -> Result<(), AsyncRocksError>
pub async fn flush(&self) -> Result<(), AsyncRocksError>
Forces a flush of memtables to SST files for the entire database.
Sourcepub async fn compact_range<K: AsRef<[u8]>>(
&self,
start: Option<K>,
end: Option<K>,
cf: Option<&str>,
) -> Result<(), AsyncRocksError>
pub async fn compact_range<K: AsRef<[u8]>>( &self, start: Option<K>, end: Option<K>, cf: Option<&str>, ) -> Result<(), AsyncRocksError>
Compacts a range of keys in the specified column family.
Sourcepub async fn all(
&self,
cf: Option<&str>,
snapshot: Option<Snapshot>,
) -> Result<Vec<(Vec<u8>, Vec<u8>)>, AsyncRocksError>
pub async fn all( &self, cf: Option<&str>, snapshot: Option<Snapshot>, ) -> Result<Vec<(Vec<u8>, Vec<u8>)>, AsyncRocksError>
Returns all key-value pairs in the specified column family.