pub struct LruCacheWithTtl<K: Hash + Eq, V: Clone> { /* private fields */ }
Implementations§
source§impl<K: Hash + Eq + Send + 'static, V: Clone + Send + 'static> LruCacheWithTtl<K, V>
impl<K: 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
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more