pub struct Cache<E, K, V, P>{ /* private fields */ }Implementations§
Source§impl<E, K, V, A> Cache<E, K, V, A>
impl<E, K, V, A> Cache<E, K, V, A>
pub fn new(engine: E, admission_policy: A) -> Self
Sourcepub fn get<Q>(&self, key: &Q) -> Option<Ref<K, V>>
pub fn get<Q>(&self, key: &Q) -> Option<Ref<K, V>>
Retrieves a value from the cache.
If the key exists, the admission policy is notified of the access.
Returns a [EntryRef] that provides controlled access to the entry.
Sourcepub fn insert(&self, key: K, value: V)
pub fn insert(&self, key: K, value: V)
Inserts a key-value pair into the cache.
When the cache is full, an eviction candidate is selected by the engine. The admission policy then decides whether the incoming entry should replace the candidate.
Returns a [EntryRef] if an existing entry was replaced.
Sourcepub fn remove<Q>(&self, key: &Q) -> bool
pub fn remove<Q>(&self, key: &Q) -> bool
Removes an entry from the cache.
Returns a [EntryRef] if the entry was present.
pub fn metrics(&self) -> MetricsSnapshot
Auto Trait Implementations§
impl<E, K, V, P> Freeze for Cache<E, K, V, P>
impl<E, K, V, P> RefUnwindSafe for Cache<E, K, V, P>
impl<E, K, V, P> Send for Cache<E, K, V, P>
impl<E, K, V, P> Sync for Cache<E, K, V, P>
impl<E, K, V, P> Unpin for Cache<E, K, V, P>
impl<E, K, V, P> UnsafeUnpin for Cache<E, K, V, P>where
E: UnsafeUnpin,
P: UnsafeUnpin,
impl<E, K, V, P> UnwindSafe for Cache<E, K, V, P>
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