Struct lruttl::LruCacheWithTtl
source · pub struct LruCacheWithTtl<K: Hash + Eq, V: Clone> { /* private fields */ }
Implementations§
source§impl<K: Hash + Eq, V: Clone> LruCacheWithTtl<K, V>
impl<K: Hash + Eq, V: Clone> LruCacheWithTtl<K, V>
pub fn new(capacity: usize) -> Self
pub fn get_with_expiry<Q>(&self, name: &Q) -> Option<(V, Instant)>
pub fn get<Q>(&self, name: &Q) -> Option<V>
pub fn insert(&self, name: K, item: V, expiration: Instant) -> V
sourcepub fn get_or_insert<F: FnOnce() -> V>(
&self,
name: K,
ttl: Duration,
func: F,
) -> V
pub fn get_or_insert<F: FnOnce() -> V>( &self, name: K, ttl: Duration, func: F, ) -> V
Get an existing item, but if that item doesn’t already exist,
call func
to provide a value that will be inserted and then
returned. This is done atomically wrt. other callers.
Auto Trait Implementations§
impl<K, V> !Freeze for LruCacheWithTtl<K, V>
impl<K, V> !RefUnwindSafe for LruCacheWithTtl<K, V>
impl<K, V> Send for LruCacheWithTtl<K, V>
impl<K, V> Sync for LruCacheWithTtl<K, V>
impl<K, V> Unpin for LruCacheWithTtl<K, V>
impl<K, V> UnwindSafe for LruCacheWithTtl<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