pub struct RandomPolicy<K> { /* private fields */ }Expand description
An eviction policy that evicts entries randomly when the cache is full.
Implementations§
Source§impl<K> RandomPolicy<K>
impl<K> RandomPolicy<K>
Trait Implementations§
Source§impl<K, V> CachePolicy<K, V> for RandomPolicy<K>
impl<K, V> CachePolicy<K, V> for RandomPolicy<K>
Source§fn on_access(&self, _key: &K, _cost: u64)
fn on_access(&self, _key: &K, _cost: u64)
A random policy does not care about access patterns. This is a no-op.
Source§fn on_admit(&self, key: &K, cost: u64) -> AdmissionDecision<K>
fn on_admit(&self, key: &K, cost: u64) -> AdmissionDecision<K>
A random policy always admits new items. We just need to start tracking it.
Auto Trait Implementations§
impl<K> !Freeze for RandomPolicy<K>
impl<K> !RefUnwindSafe for RandomPolicy<K>
impl<K> Send for RandomPolicy<K>where
K: Send,
impl<K> Sync for RandomPolicy<K>where
K: Send,
impl<K> Unpin for RandomPolicy<K>where
K: Unpin,
impl<K> UnwindSafe for RandomPolicy<K>where
K: 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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more