pub struct WTinyLfuCache<K, V> { /* private fields */ }Expand description
Implementations§
Source§impl<K, V> WTinyLfuCache<K, V>
impl<K, V> WTinyLfuCache<K, V>
Sourcepub fn new(total_cap: usize) -> Self
pub fn new(total_cap: usize) -> Self
Create a new WTinyLfuCache with the given total capacity.
Minimum capacity is 2.
Sourcepub fn get(&mut self, key: &K) -> Option<&V>
pub fn get(&mut self, key: &K) -> Option<&V>
Look up key, updating recency and frequency.
Expired entries are lazily removed and treated as misses.
Sourcepub fn put(&mut self, key: K, value: V) -> Option<V>
pub fn put(&mut self, key: K, value: V) -> Option<V>
Insert or update key -> value without TTL.
Sourcepub fn put_with_ttl(&mut self, key: K, value: V, ttl: Duration) -> Option<V>
pub fn put_with_ttl(&mut self, key: K, value: V, ttl: Duration) -> Option<V>
Insert or update key -> value with a TTL.
Sourcepub fn peek(&self, key: &K) -> Option<&V>
pub fn peek(&self, key: &K) -> Option<&V>
Read a value without updating recency or frequency.
Returns None if absent or expired.
Sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
Return true if key is present and not expired (no recency update).
Trait Implementations§
Source§impl<K, V> Cache<K, V> for WTinyLfuCache<K, V>
impl<K, V> Cache<K, V> for WTinyLfuCache<K, V>
Source§fn get(&mut self, key: &K) -> Option<&V>
fn get(&mut self, key: &K) -> Option<&V>
Look up
key, returning a reference to the value if present. Read moreSource§fn put_with_ttl(&mut self, key: K, value: V, ttl: Duration) -> Option<V>
fn put_with_ttl(&mut self, key: K, value: V, ttl: Duration) -> Option<V>
Source§fn remove(&mut self, key: &K) -> Option<V>
fn remove(&mut self, key: &K) -> Option<V>
Remove the entry associated with
key, returning its value if present. Read moreSource§fn peek(&self, key: &K) -> Option<&V>
fn peek(&self, key: &K) -> Option<&V>
Look up
key without updating access metadata (no promotion). Read moreSource§fn contains_key(&self, key: &K) -> bool
fn contains_key(&self, key: &K) -> bool
Auto Trait Implementations§
impl<K, V> Freeze for WTinyLfuCache<K, V>
impl<K, V> RefUnwindSafe for WTinyLfuCache<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for WTinyLfuCache<K, V>
impl<K, V> Sync for WTinyLfuCache<K, V>
impl<K, V> Unpin for WTinyLfuCache<K, V>where
K: Unpin,
impl<K, V> UnsafeUnpin for WTinyLfuCache<K, V>
impl<K, V> UnwindSafe for WTinyLfuCache<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