pub struct Cache<K, V, W = ItemCountWeighter, H = FastBuildHasher> { /* private fields */ }
Expand description
A simple concurrent cache.
Implementations§
Source§impl<K, V, W, H> Cache<K, V, W, H>
impl<K, V, W, H> Cache<K, V, W, H>
Sourcepub fn insert(&self, key: K, value: V)
pub fn insert(&self, key: K, value: V)
Inserts an item into the cache with the given key and value.
If an item with the same key already exists, it will be overwritten and the old value will be dropped. If the cache is full, one or more items will be evicted to make room for the new item, based on the configured item weighter and the weight of the new item.
Trait Implementations§
Auto Trait Implementations§
impl<K, V, W, H> Freeze for Cache<K, V, W, H>
impl<K, V, W = ItemCountWeighter, H = RandomState> !RefUnwindSafe for Cache<K, V, W, H>
impl<K, V, W, H> Send for Cache<K, V, W, H>
impl<K, V, W, H> Sync for Cache<K, V, W, H>
impl<K, V, W, H> Unpin for Cache<K, V, W, H>
impl<K, V, W = ItemCountWeighter, H = RandomState> !UnwindSafe for Cache<K, V, W, H>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Track for T
impl<T> Track for T
§fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
Instruments this type by attaching the given allocation group token, returning a
Tracked
wrapper. Read more§fn in_current_allocation_group(self) -> Tracked<Self>
fn in_current_allocation_group(self) -> Tracked<Self>
Instruments this type by attaching the current allocation group, returning a
Tracked
wrapper. Read more