pub struct ClockCache<K, V>{ /* private fields */ }Expand description
Concurrent fixed-size Clock cache.
Maintains a mapping from keys → slot indices and uses a clock-hand eviction policy.
Implementations§
Source§impl<K, V> ClockCache<K, V>
impl<K, V> ClockCache<K, V>
Sourcepub fn new(
capacity: usize,
backoff_config: BackoffConfig,
metrics_config: MetricsConfig,
) -> Self
pub fn new( capacity: usize, backoff_config: BackoffConfig, metrics_config: MetricsConfig, ) -> Self
Create a new Clock cache with the given capacity.
Trait Implementations§
Source§impl<K, V> CacheEngine<K, V> for ClockCache<K, V>
impl<K, V> CacheEngine<K, V> for ClockCache<K, V>
Source§fn get<Q>(&self, key: &Q) -> Option<Ref<K, V>>
fn get<Q>(&self, key: &Q) -> Option<Ref<K, V>>
Get a value by key.
Returns a Handler that pins the entry in memory.
Source§fn insert_with<F>(
&self,
key: K,
value: V,
expired_at: Option<Instant>,
admission: F,
)
fn insert_with<F>( &self, key: K, value: V, expired_at: Option<Instant>, admission: F, )
Inserts a key-value pair with a custom admission policy. Read more
Source§fn metrics(&self) -> MetricsSnapshot
fn metrics(&self) -> MetricsSnapshot
Returns a snapshot of internal cache statistics.
Auto Trait Implementations§
impl<K, V> !Freeze for ClockCache<K, V>
impl<K, V> !RefUnwindSafe for ClockCache<K, V>
impl<K, V> Send for ClockCache<K, V>
impl<K, V> Sync for ClockCache<K, V>
impl<K, V> Unpin for ClockCache<K, V>
impl<K, V> UnsafeUnpin for ClockCache<K, V>
impl<K, V> UnwindSafe for ClockCache<K, V>where
V: RefUnwindSafe,
K: RefUnwindSafe,
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