pub struct CellLruCache<K, V> { /* private fields */ }Expand description
A wrapper around LruCache to provide shared & access to content.
Implementations§
Source§impl<K, V> CellLruCache<K, V>
impl<K, V> CellLruCache<K, V>
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of key-value pairs that are currently in the cache.
Sourcepub fn get_or_put<F>(&self, key: K, f: F) -> V
pub fn get_or_put<F>(&self, key: K, f: F) -> V
Return the value of they key in the cache otherwise computes the value and inserts it into the cache. If the key is already in the cache, they get moved to the head of the LRU list.
Sourcepub fn get_or_try_put<F, E>(&self, key: K, f: F) -> Result<V, E>
pub fn get_or_try_put<F, E>(&self, key: K, f: F) -> Result<V, E>
Returns the value of they key in the cache if present, otherwise computes the value using the provided closure.
If the key is already in the cache, it gets moved to the head of the LRU list.
If the provided closure fails, the error is returned and the cache is not updated.
Sourcepub fn put(&self, key: K, value: V)
pub fn put(&self, key: K, value: V)
Puts a key-value pair into cache. If the key already exists in the cache, then it updates the key’s value.
pub fn pop<Q>(&self, key: &Q) -> Option<V>
Auto Trait Implementations§
impl<K, V> !Freeze for CellLruCache<K, V>
impl<K, V> !RefUnwindSafe for CellLruCache<K, V>
impl<K, V> Send for CellLruCache<K, V>
impl<K, V> !Sync for CellLruCache<K, V>
impl<K, V> Unpin for CellLruCache<K, V>
impl<K, V> UnwindSafe for CellLruCache<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
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