Struct StorageInternalCache

Source
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

Source

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.

Source

pub fn try_get(&self, key: &StorageKey) -> ValueExists

Gets a keyed value from the cache, returning a wrapper on whether it exists.

Source

pub fn set(&mut self, key: &StorageKey, value: StorageValue)

Replaces the keyed value on the storage.

Source

pub fn delete(&mut self, key: &StorageKey)

Deletes a keyed value from the cache.

Source

pub fn merge_left(&mut self, rhs: Self) -> Result<(), MergeError>

Merges the provided StorageInternalCache into this one.

Source

pub fn merge_reads_left(&mut self, rhs: Self) -> Result<(), MergeError>

Merges the reads of the provided StorageInternalCache into this one.

Source

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

Source§

fn default() -> StorageInternalCache

Returns the “default value” for a type. Read more
Source§

impl From<StorageInternalCache> for CacheLog

Source§

fn from(val: StorageInternalCache) -> Self

Converts to this type from the input type.
Source§

impl From<StorageInternalCache> for OrderedReadsAndWrites

Source§

fn from(val: StorageInternalCache) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more