pub struct StorageInternalCache {
pub tx_cache: CacheLog,
pub ordered_db_reads: Vec<(CacheKey, Option<CacheValue>)>,
}
Expand description
Caches reads and writes for a (key, value) pair. On the first read the value is fetched
from an external source represented by the ValueReader
trait. On following reads,
the cache checks if the value we read was inserted before.
Fields§
§tx_cache: CacheLog
Transaction cache.
ordered_db_reads: Vec<(CacheKey, Option<CacheValue>)>
Ordered reads and writes.
Implementations§
Source§impl StorageInternalCache
impl StorageInternalCache
Sourcepub fn get_or_fetch<S: Storage>(
&mut self,
key: &StorageKey,
value_reader: &S,
witness: &S::Witness,
) -> Option<StorageValue>
pub fn get_or_fetch<S: Storage>( &mut self, key: &StorageKey, value_reader: &S, witness: &S::Witness, ) -> Option<StorageValue>
Gets a value from the cache or reads it from the provided ValueReader
.
Sourcepub fn try_get(&self, key: &StorageKey) -> ValueExists
pub fn try_get(&self, key: &StorageKey) -> ValueExists
Gets a keyed value from the cache, returning a wrapper on whether it exists.
Sourcepub fn set(&mut self, key: &StorageKey, value: StorageValue)
pub fn set(&mut self, key: &StorageKey, value: StorageValue)
Replaces the keyed value on the storage.
Sourcepub fn delete(&mut self, key: &StorageKey)
pub fn delete(&mut self, key: &StorageKey)
Deletes a keyed value from the cache.
Sourcepub fn merge_left(&mut self, rhs: Self) -> Result<(), MergeError>
pub fn merge_left(&mut self, rhs: Self) -> Result<(), MergeError>
Merges the provided StorageInternalCache
into this one.
Sourcepub fn merge_reads_left(&mut self, rhs: Self) -> Result<(), MergeError>
pub fn merge_reads_left(&mut self, rhs: Self) -> Result<(), MergeError>
Merges the reads of the provided StorageInternalCache
into this one.
Sourcepub fn merge_writes_left(&mut self, rhs: Self) -> Result<(), MergeError>
pub fn merge_writes_left(&mut self, rhs: Self) -> Result<(), MergeError>
Merges the writes of the provided StorageInternalCache
into this one.
Trait Implementations§
Source§impl Default for StorageInternalCache
impl Default for StorageInternalCache
Source§fn default() -> StorageInternalCache
fn default() -> StorageInternalCache
Returns the “default value” for a type. Read more
Source§impl From<StorageInternalCache> for CacheLog
impl From<StorageInternalCache> for CacheLog
Source§fn from(val: StorageInternalCache) -> Self
fn from(val: StorageInternalCache) -> Self
Converts to this type from the input type.
Source§impl From<StorageInternalCache> for OrderedReadsAndWrites
impl From<StorageInternalCache> for OrderedReadsAndWrites
Source§fn from(val: StorageInternalCache) -> Self
fn from(val: StorageInternalCache) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for StorageInternalCache
impl RefUnwindSafe for StorageInternalCache
impl Send for StorageInternalCache
impl Sync for StorageInternalCache
impl Unpin for StorageInternalCache
impl UnwindSafe for StorageInternalCache
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