pub struct AutoCache<K, V>where
K: Hash + Eq + Clone + Send + Sync + HeapSize + 'static,
V: Clone + Send + Sync + HeapSize + 'static,{ /* private fields */ }Expand description
High-performance multi-tiered cache with automatic sizing
Implementations§
Source§impl<K, V> AutoCache<K, V>
impl<K, V> AutoCache<K, V>
Sourcepub fn new(config: CacheConfig) -> Self
pub fn new(config: CacheConfig) -> Self
Creates a new cache
Sourcepub async fn get_or_update<F, Fut>(&self, key: K, updater: F) -> Option<Arc<V>>
pub async fn get_or_update<F, Fut>(&self, key: K, updater: F) -> Option<Arc<V>>
Gets or updates a cache entry asynchronously
Sourcepub fn subscribe_updates(&self) -> Receiver<K>
pub fn subscribe_updates(&self) -> Receiver<K>
Subscribes to cache updates
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Gets cache statistics
Auto Trait Implementations§
impl<K, V> Freeze for AutoCache<K, V>
impl<K, V> !RefUnwindSafe for AutoCache<K, V>
impl<K, V> Send for AutoCache<K, V>
impl<K, V> Sync for AutoCache<K, V>
impl<K, V> Unpin for AutoCache<K, V>
impl<K, V> !UnwindSafe for AutoCache<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
Source§impl<T> ValueSize for T
impl<T> ValueSize for T
Source§fn value_size(&self) -> usize
fn value_size(&self) -> usize
The size of this value in bytes, excluding allocated data. Read more
Source§fn value_size_sum_iter<'item>(iterator: impl Iterator<Item = &'item T>) -> usizewhere
T: 'item,
fn value_size_sum_iter<'item>(iterator: impl Iterator<Item = &'item T>) -> usizewhere
T: 'item,
The total sum of the sizes of all values in the given iterator, in
bytes. This is default-implemented by computing ValueSize::value_size
on every element and summing them. For Sized types, a more potentially
efficient implementation using Iterator::count is provided. If you are
implementing this trait manually, it is unlikely to be more efficient to
provide a manual implementation here. Read more
Source§fn value_size_sum_exact_size_iter<'item>(
iterator: impl ExactSizeIterator<Item = &'item T>,
) -> usizewhere
T: 'item,
fn value_size_sum_exact_size_iter<'item>(
iterator: impl ExactSizeIterator<Item = &'item T>,
) -> usizewhere
T: 'item,
The total sum of the sizes of all values in the given
exact-size-iterator, in bytes. This is default-implemented by using
ValueSize::value_size_sum_iter. For Sized types, a usually more
efficient implementation using ExactSizeIterator::len is provided. If
you are implementing this trait manually, it is unlikely to be more
efficient to provide a manual implementation here. Read more