pub struct LruCacheWithTtl<K: Clone + Hash + Eq, V: Clone> { /* private fields */ }
Implementations§
source§impl<K: Clone + Hash + Eq + Send + 'static, V: Clone + Send + 'static> LruCacheWithTtl<K, V>
impl<K: Clone + Hash + Eq + Send + 'static, V: Clone + Send + 'static> LruCacheWithTtl<K, V>
pub fn new(capacity: usize) -> Self
👎Deprecated: use new_named instead
pub fn new_named<S: Into<String>>(name: S, capacity: usize) -> Self
pub fn clear(&self) -> usize
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
pub fn prune_expired(&self) -> usize
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>
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