pub struct OptimisticDb<K, V, SP: AsyncSpawner, S = RandomState> { /* private fields */ }
Expand description
A concurrent MVCC in-memory key-value database.
OptimisticDb
requires key to be Ord
and Hash
.
Comparing to SerializableDb
:
SerializableDb
support full serializable snapshot isolation, which can detect both direct dependencies and indirect dependencies.SerializableDb
does not require key to implementHash
.- But,
OptimisticDb
has more flexible write transaction APIs and no clone happen.
Implementations§
Source§impl<K, V, SP: AsyncSpawner> OptimisticDb<K, V, SP>
impl<K, V, SP: AsyncSpawner> OptimisticDb<K, V, SP>
Source§impl<K, V, SP: AsyncSpawner, S> OptimisticDb<K, V, SP, S>
impl<K, V, SP: AsyncSpawner, S> OptimisticDb<K, V, SP, S>
Sourcepub async fn with_hasher(hasher: S) -> Self
pub async fn with_hasher(hasher: S) -> Self
Creates a new OptimisticDb
with the given hasher.
Sourcepub async fn read(
&self,
) -> ReadTransaction<K, V, OptimisticDb<K, V, SP, S>, HashCm<K, S>, SP>
pub async fn read( &self, ) -> ReadTransaction<K, V, OptimisticDb<K, V, SP, S>, HashCm<K, S>, SP>
Create a read transaction.
Source§impl<K, V, SP, S> OptimisticDb<K, V, SP, S>
impl<K, V, SP, S> OptimisticDb<K, V, SP, S>
Sourcepub async fn write(&self) -> OptimisticTransaction<K, V, SP, S>
pub async fn write(&self) -> OptimisticTransaction<K, V, SP, S>
Create a write transaction.
Sourcepub async fn write_with_capacity(
&self,
capacity: usize,
) -> OptimisticTransaction<K, V, SP, S>
pub async fn write_with_capacity( &self, capacity: usize, ) -> OptimisticTransaction<K, V, SP, S>
Create a write transaction with the given capacity hint.
Trait Implementations§
Source§impl<K, V, SP, S> Clone for OptimisticDb<K, V, SP, S>where
SP: AsyncSpawner,
impl<K, V, SP, S> Clone for OptimisticDb<K, V, SP, S>where
SP: AsyncSpawner,
Auto Trait Implementations§
impl<K, V, SP, S> Freeze for OptimisticDb<K, V, SP, S>
impl<K, V, SP, S = RandomState> !RefUnwindSafe for OptimisticDb<K, V, SP, S>
impl<K, V, SP, S> Send for OptimisticDb<K, V, SP, S>
impl<K, V, SP, S> Sync for OptimisticDb<K, V, SP, S>
impl<K, V, SP, S> Unpin for OptimisticDb<K, V, SP, S>
impl<K, V, SP, S = RandomState> !UnwindSafe for OptimisticDb<K, V, SP, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more