Struct skipdb::optimistic::OptimisticDb
source · pub struct OptimisticDb<K, V, 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> OptimisticDb<K, V>
impl<K, V> OptimisticDb<K, V>
source§impl<K, V, S> OptimisticDb<K, V, S>
impl<K, V, S> OptimisticDb<K, V, S>
sourcepub fn with_hasher(hasher: S) -> Self
pub fn with_hasher(hasher: S) -> Self
Creates a new OptimisticDb
with the given hasher.
sourcepub fn read(&self) -> ReadTransaction<K, V, OptimisticDb<K, V, S>, HashCm<K, S>>
pub fn read(&self) -> ReadTransaction<K, V, OptimisticDb<K, V, S>, HashCm<K, S>>
Create a read transaction.
source§impl<K, V, S> OptimisticDb<K, V, S>
impl<K, V, S> OptimisticDb<K, V, S>
sourcepub fn write(&self) -> OptimisticTransaction<K, V, S>
pub fn write(&self) -> OptimisticTransaction<K, V, S>
Create a optimistic write transaction.
Optimistic write transaction is not a totally Serializable Snapshot Isolation transaction.
It can handle most of write skew anomaly, but not all. Basically, all directly dependencies
can be handled, but indirect dependencies (logical dependencies) can not be handled.
If you need a totally Serializable Snapshot Isolation transaction, you should use
SerializableDb
instead.
sourcepub fn write_with_capacity(
&self,
capacity: usize
) -> OptimisticTransaction<K, V, S>
pub fn write_with_capacity( &self, capacity: usize ) -> OptimisticTransaction<K, V, S>
Create a optimistic write transaction with the given capacity hint.
Trait Implementations§
source§impl<K, V, S> Clone for OptimisticDb<K, V, S>
impl<K, V, S> Clone for OptimisticDb<K, V, S>
Auto Trait Implementations§
impl<K, V, S> Freeze for OptimisticDb<K, V, S>
impl<K, V, S = RandomState> !RefUnwindSafe for OptimisticDb<K, V, S>
impl<K, V, S> Send for OptimisticDb<K, V, S>
impl<K, V, S> Sync for OptimisticDb<K, V, S>
impl<K, V, S> Unpin for OptimisticDb<K, V, S>
impl<K, V, S = RandomState> !UnwindSafe for OptimisticDb<K, V, 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> 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