AsyncRocksDB

Struct AsyncRocksDB 

Source
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

Source

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).

Source

pub fn snapshot(&self) -> Snapshot

Creates a new snapshot of the current database state.

Source

pub async fn put<K, V>( &self, key: K, value: V, cf: Option<&str>, ) -> Result<(), AsyncRocksError>
where K: AsRef<[u8]> + Send + 'static, V: AsRef<[u8]> + Send + 'static,

Inserts a key-value pair into the database.

cf specifies the column family. Use None for the default column family.

Source

pub async fn get<K>( &self, key: K, cf: Option<&str>, snapshot: Option<Snapshot>, ) -> Result<Option<Vec<u8>>, AsyncRocksError>
where K: AsRef<[u8]> + Send + 'static,

Retrieves a value by key.

Returns None if the key does not exist. Use snapshot for reading from a point-in-time view.

Source

pub async fn delete<K>( &self, key: K, cf: Option<&str>, ) -> Result<(), AsyncRocksError>
where K: AsRef<[u8]> + Send + 'static,

Deletes a key from the database.

Source

pub async fn multi_get<K>( &self, keys: Vec<K>, cf: Option<&str>, snapshot: Option<Snapshot>, ) -> Result<Vec<Option<Vec<u8>>>, AsyncRocksError>
where K: AsRef<[u8]> + Send + 'static,

Retrieves multiple values by keys in a single operation.

Returns a Vec with the same length as keys, containing Some(value) or None.

Source

pub async fn multi_delete<K>( &self, keys: Vec<K>, cf: Option<&str>, ) -> Result<(), AsyncRocksError>
where K: AsRef<[u8]> + Send + 'static,

Deletes multiple keys in a single operation.

Source

pub async fn flush(&self) -> Result<(), AsyncRocksError>

Forces a flush of memtables to SST files for the entire database.

Source

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.

Source

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.

Source

pub async fn prefix_all<P>( &self, prefix: P, cf: Option<&str>, snapshot: Option<Snapshot>, ) -> Result<Vec<(Vec<u8>, Vec<u8>)>, AsyncRocksError>
where P: AsRef<[u8]> + Send + 'static,

Returns all key-value pairs matching the given prefix.

Uses RocksDB’s prefix seek optimization for high performance.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.