pub struct SerializableDb<K, V, S: AsyncSpawner> { /* private fields */ }
Expand description
A concurrent MVCC in-memory key-value database.
SerializableDb
requires key to be Ord
and CheapClone
.
The CheapClone
bound here hints the user that the key should be cheap to clone,
because it will be cloned at least one time during the write transaction.
Comparing to OptimisticDb
:
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.
Implementations§
Source§impl<K, V, S: AsyncSpawner> SerializableDb<K, V, S>
impl<K, V, S: AsyncSpawner> SerializableDb<K, V, S>
Source§impl<K, V, S: AsyncSpawner> SerializableDb<K, V, S>
impl<K, V, S: AsyncSpawner> SerializableDb<K, V, S>
Sourcepub async fn read(
&self,
) -> ReadTransaction<K, V, SerializableDb<K, V, S>, BTreeCm<K>, S>
pub async fn read( &self, ) -> ReadTransaction<K, V, SerializableDb<K, V, S>, BTreeCm<K>, S>
Create a read transaction.
Source§impl<K, V, S> SerializableDb<K, V, S>
impl<K, V, S> SerializableDb<K, V, S>
Sourcepub async fn optimistic_write(&self) -> OptimisticTransaction<K, V, S>
pub async fn optimistic_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::serializable_write
instead.
Sourcepub async fn serializable_write(&self) -> SerializableTransaction<K, V, S>
pub async fn serializable_write(&self) -> SerializableTransaction<K, V, S>
Create a serializable write transaction.
Serializable write transaction is a totally Serializable Snapshot Isolation transaction.
It can handle all kinds of write skew anomaly, including indirect dependencies (logical dependencies).
If in your code, you do not care about indirect dependencies (logical dependencies), you can use
SerializableDb::optimistic_write
instead.
Source§impl<K, V, S> SerializableDb<K, V, S>
impl<K, V, S> SerializableDb<K, V, S>
Trait Implementations§
Source§impl<K, V, S: AsyncSpawner> Clone for SerializableDb<K, V, S>
impl<K, V, S: AsyncSpawner> Clone for SerializableDb<K, V, S>
Auto Trait Implementations§
impl<K, V, S> Freeze for SerializableDb<K, V, S>
impl<K, V, S> !RefUnwindSafe for SerializableDb<K, V, S>
impl<K, V, S> Send for SerializableDb<K, V, S>
impl<K, V, S> Sync for SerializableDb<K, V, S>
impl<K, V, S> Unpin for SerializableDb<K, V, S>
impl<K, V, S> !UnwindSafe for SerializableDb<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
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>
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>
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