pub struct LruCache<K, V> { /* private fields */ }Expand description
A process-local, bounded least-recently-used cache with TTL expiration.
Implementations§
Source§impl<K: Eq + Hash + Clone, V: Clone> LruCache<K, V>
impl<K: Eq + Hash + Clone, V: Clone> LruCache<K, V>
Sourcepub fn insert(&self, key: K, value: V, ttl_secs: u64)
pub fn insert(&self, key: K, value: V, ttl_secs: u64)
Inserts or replaces a value with a TTL measured from this call.
Sourcepub fn get(&self, key: &K) -> Option<V>
pub fn get(&self, key: &K) -> Option<V>
Returns an unexpired value and records this lookup as the latest access.
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Returns a point-in-time statistics snapshot.
Auto Trait Implementations§
impl<K, V> !Freeze for LruCache<K, V>
impl<K, V> !RefUnwindSafe for LruCache<K, V>
impl<K, V> !UnwindSafe for LruCache<K, V>
impl<K, V> Send for LruCache<K, V>
impl<K, V> Sync for LruCache<K, V>
impl<K, V> Unpin for LruCache<K, V>
impl<K, V> UnsafeUnpin for LruCache<K, V>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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