Struct async_skipdb::optimistic::OptimisticDb
source · 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> 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