pub struct ClockProCache<K, V> { /* private fields */ }
Expand description
A CLOCK-Pro cache that maps keys to values.
Implementations§
Source§impl<K, V> ClockProCache<K, V>
impl<K, V> ClockProCache<K, V>
Sourcepub fn new(capacity: usize) -> Result<Self, &'static str>
pub fn new(capacity: usize) -> Result<Self, &'static str>
Create a new cache with the given capacity.
Sourcepub fn new_with_test_capacity(
capacity: usize,
test_capacity: usize,
) -> Result<Self, &'static str>
pub fn new_with_test_capacity( capacity: usize, test_capacity: usize, ) -> Result<Self, &'static str>
Create a new cache with the given value and test capacities.
The test capacity is used for tracking recently evicted entries, so that they will be considered frequently used if they get reinserted.
Sourcepub fn recent_len(&self) -> usize
pub fn recent_len(&self) -> usize
Returns the number of recently inserted values.
Sourcepub fn frequent_len(&self) -> usize
pub fn frequent_len(&self) -> usize
Returns the number of frequently fetched or updated values.
Sourcepub fn inserted(&self) -> u64
pub fn inserted(&self) -> u64
Returns how many values have been inserted into the cache overall.
Sourcepub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
Get a mutable reference to the value in the cache mapped to by key
.
If no value exists for key
, this returns None
.
Sourcepub fn get<Q>(&mut self, key: &Q) -> Option<&V>
pub fn get<Q>(&mut self, key: &Q) -> Option<&V>
Get an immutable reference to the value in the cache mapped to by key
.
If no value exists for key
, this returns None
.
Sourcepub fn contains_key<Q>(&mut self, key: &Q) -> bool
pub fn contains_key<Q>(&mut self, key: &Q) -> bool
Returns true
if there is a value in the cache mapped to by key
.
Trait Implementations§
impl<K, V> Send for ClockProCache<K, V>
impl<K, V> Sync for ClockProCache<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for ClockProCache<K, V>
impl<K, V> RefUnwindSafe for ClockProCache<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Unpin for ClockProCache<K, V>
impl<K, V> UnwindSafe for ClockProCache<K, V>where
K: UnwindSafe,
V: UnwindSafe,
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