Struct sp_trie::cache::SharedTrieCache
source · pub struct SharedTrieCache<H: Hasher> { /* private fields */ }
Expand description
The shared trie cache.
It should be instantiated once per node. It will hold the trie nodes and values of all
operations to the state. To not use all available memory it will ensure to stay in the
bounds given via the CacheSize
at startup.
The instance of this object can be shared between multiple threads.
Implementations§
sourcepub fn new(cache_size: CacheSize) -> Self
pub fn new(cache_size: CacheSize) -> Self
Create a new SharedTrieCache
.
sourcepub fn local_cache(&self) -> LocalTrieCache<H>
pub fn local_cache(&self) -> LocalTrieCache<H>
Create a new LocalTrieCache
instance from this shared cache.
sourcepub fn peek_node(&self, key: &H::Out) -> Option<NodeOwned<H::Out>>
pub fn peek_node(&self, key: &H::Out) -> Option<NodeOwned<H::Out>>
Get a copy of the node for key
.
This will temporarily lock the shared cache for reading.
This doesn’t change the least recently order in the internal LruMap
.
sourcepub fn peek_value_by_hash(
&self,
hash: ValueCacheKeyHash,
storage_root: &H::Out,
storage_key: &[u8]
) -> Option<CachedValue<H::Out>>
pub fn peek_value_by_hash( &self, hash: ValueCacheKeyHash, storage_root: &H::Out, storage_key: &[u8] ) -> Option<CachedValue<H::Out>>
Get a copy of the CachedValue
for key
.
This will temporarily lock the shared cache for reading.
This doesn’t reorder any of the elements in the internal LruMap
.
sourcepub fn used_memory_size(&self) -> usize
pub fn used_memory_size(&self) -> usize
Returns the used memory size of this cache in bytes.
sourcepub fn reset_node_cache(&self)
pub fn reset_node_cache(&self)
Reset the node cache.
sourcepub fn reset_value_cache(&self)
pub fn reset_value_cache(&self)
Reset the value cache.
Trait Implementations§
Auto Trait Implementations§
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> 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, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.