pub struct Cache<E, K, V>{ /* private fields */ }Implementations§
Source§impl<E, K, V> Cache<E, K, V>
impl<E, K, V> Cache<E, K, V>
pub fn new(engine: E, backoff_config: BackoffConfig) -> 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 Ref handle that provides controlled access to the entry.
The entry is pinned in memory for the duration of the handle’s life using epoch-based memory reclamation.
Sourcepub fn insert(&self, key: K, value: V)
pub fn insert(&self, key: K, value: V)
Inserts a key-value pair into the cache.
§Arguments
key- The key to associate with the value.value- The value to be cached.
Sourcepub fn insert_with_ttl(&self, key: K, value: V, ttl: Duration)
pub fn insert_with_ttl(&self, key: K, value: V, ttl: Duration)
Inserts a key-value pair into the cache with a specific Time-to-Live (TTL).
The entry will be automatically considered expired after the specified ttl
duration has elapsed.
§Arguments
key- The key to associate with the value.value- The value to be cached.ttl- The duration for which the entry should remain valid.
Sourcepub fn remove<Q>(&self, key: &Q) -> bool
pub fn remove<Q>(&self, key: &Q) -> bool
Removes an entry from the cache.
Returns true if the entry was found and successfully removed.
pub fn metrics(&self) -> MetricsSnapshot
Auto Trait Implementations§
impl<E, K, V> !Freeze for Cache<E, K, V>
impl<E, K, V> RefUnwindSafe for Cache<E, K, V>
impl<E, K, V> Send for Cache<E, K, V>
impl<E, K, V> Sync for Cache<E, K, V>
impl<E, K, V> Unpin for Cache<E, K, V>
impl<E, K, V> UnsafeUnpin for Cache<E, K, V>where
E: UnsafeUnpin,
impl<E, K, V> UnwindSafe for Cache<E, 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