pub struct RcuCache<K, V, S = RapidBuildHasher>where
K: Eq + Hash + Clone + Send + Sync + 'static,
V: Clone + Send + Sync + 'static,
S: BuildHasher + Send + Sync + 'static,{ /* private fields */ }Expand description
A cache that uses RCU to provide thread-safe access to a hash map.
This is similar to RcuHashMap, but it also evicts items when the cache
exceeds a specified capacity.
Entries are evicted in a FIFO manner.
By default, this map uses rapidhash::RapidBuildHasher, which provides high performance.
However, if this map holds keys which may be attacker-controlled, consider using
std::collections::hash_map::RandomState instead.
Implementations§
Source§impl<K, V> RcuCache<K, V, RapidBuildHasher>
impl<K, V> RcuCache<K, V, RapidBuildHasher>
Source§impl<K, V, S> RcuCache<K, V, S>
impl<K, V, S> RcuCache<K, V, S>
Sourcepub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
Creates a new RcuCache with the specified capacity and hasher.
Trait Implementations§
Auto Trait Implementations§
impl<K, V, S = BuildHasherDefault<RapidHasher>> !Freeze for RcuCache<K, V, S>
impl<K, V, S = BuildHasherDefault<RapidHasher>> !RefUnwindSafe for RcuCache<K, V, S>
impl<K, V, S> Send for RcuCache<K, V, S>
impl<K, V, S> Sync for RcuCache<K, V, S>
impl<K, V, S> Unpin for RcuCache<K, V, S>
impl<K, V, S> UnsafeUnpin for RcuCache<K, V, S>where
S: UnsafeUnpin,
impl<K, V, S> UnwindSafe for RcuCache<K, V, S>
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
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
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