pub struct LruCacheWithTtl<K: Clone + Debug + Hash + Eq, V: Clone + Debug + Send + Sync> { /* private fields */ }
Implementations§
Source§impl<K: Clone + Debug + Hash + Eq + Send + Sync + Debug + 'static, V: Clone + Debug + Send + Sync + 'static> LruCacheWithTtl<K, V>
impl<K: Clone + Debug + Hash + Eq + Send + Sync + Debug + 'static, V: Clone + Debug + Send + Sync + 'static> LruCacheWithTtl<K, V>
pub fn new<S: Into<String>>(name: S, capacity: usize) -> Self
pub fn set_retry_on_sema_timeout(&self, value: bool)
pub fn set_sema_timeout(&self, duration: Duration)
pub fn clear(&self) -> usize
pub async fn lookup<Q>(&self, name: &Q) -> Option<ItemLookup<V>>
pub async fn get<Q>(&self, name: &Q) -> Option<V>
pub async fn insert(&self, name: K, item: V, expiration: Instant) -> V
Sourcepub async fn get_or_try_insert<E: Into<Error>, TTL: FnOnce(&V) -> Duration>(
&self,
name: &K,
ttl_func: TTL,
fut: impl Future<Output = Result<V, E>>,
) -> Result<ItemLookup<V>, Arc<Error>>
pub async fn get_or_try_insert<E: Into<Error>, TTL: FnOnce(&V) -> Duration>( &self, name: &K, ttl_func: TTL, fut: impl Future<Output = Result<V, E>>, ) -> Result<ItemLookup<V>, Arc<Error>>
Get an existing item, but if that item doesn’t already exist,
execute the future fut
to provide a value that will be inserted and then
returned. This is done atomically wrt. other callers.
The TTL parameter is a function that can extract the TTL from the value type,
or just return a constant TTL.
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