pub struct LruResultCache { /* private fields */ }Expand description
In-memory LRU cache. Hand-rolled to avoid the lru crate
dependency — the substrate already has intrusive lists in
several places and the implementation is ~80 lines.
Implementations§
Trait Implementations§
Source§impl Default for LruResultCache
impl Default for LruResultCache
Source§impl ResultCache for LruResultCache
impl ResultCache for LruResultCache
Source§fn get(&self, key: &CacheKey) -> Option<CachedResult>
fn get(&self, key: &CacheKey) -> Option<CachedResult>
Look up an entry. Returns
Some only when the entry is
present AND unexpired AND its capability_version
matches key.capability_version (the latter is
enforced by the key itself — entries inserted under a
different version simply don’t collide).Source§fn insert(&self, key: CacheKey, result: CachedResult)
fn insert(&self, key: CacheKey, result: CachedResult)
Insert a fresh entry. Replaces any prior entry at the
same key; trips LRU eviction if the cache is full.
Source§fn invalidate_all(&self)
fn invalidate_all(&self)
Drop every entry. Used by tests + explicit operator
flushes; not on the hot path.
Auto Trait Implementations§
impl !Freeze for LruResultCache
impl !RefUnwindSafe for LruResultCache
impl Send for LruResultCache
impl Sync for LruResultCache
impl Unpin for LruResultCache
impl UnsafeUnpin for LruResultCache
impl UnwindSafe for LruResultCache
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