pub struct SetAssociativeCache<E: KeyExtract, S: BuildHasher, L: CacheLayout, A: Allocator = Global> {
pub metrics: Metrics,
/* private fields */
}Expand description
A set-associative cache with CLOCK eviction, SIMD tag matching, and custom allocator support.
Fields§
§metrics: MetricsCache hit/miss metrics.
Implementations§
Source§impl<E: KeyExtract, S: BuildHasher + Default, L: CacheLayout> SetAssociativeCache<E, S, L>
impl<E: KeyExtract, S: BuildHasher + Default, L: CacheLayout> SetAssociativeCache<E, S, L>
Source§impl<E: KeyExtract, S: BuildHasher, L: CacheLayout> SetAssociativeCache<E, S, L>
impl<E: KeyExtract, S: BuildHasher, L: CacheLayout> SetAssociativeCache<E, S, L>
Sourcepub fn with_hasher(value_count_max: u64, hash_builder: S) -> Self
pub fn with_hasher(value_count_max: u64, hash_builder: S) -> Self
Create a new cache with the given hasher and global allocator.
Source§impl<E: KeyExtract, S: BuildHasher, L: CacheLayout, A: Allocator> SetAssociativeCache<E, S, L, A>
impl<E: KeyExtract, S: BuildHasher, L: CacheLayout, A: Allocator> SetAssociativeCache<E, S, L, A>
Sourcepub fn with_hasher_and_alloc(
value_count_max: u64,
hash_builder: S,
alloc: A,
) -> Self
pub fn with_hasher_and_alloc( value_count_max: u64, hash_builder: S, alloc: A, ) -> Self
Create a new cache with the given hasher and allocator.
Sourcepub fn value_count_max_multiple() -> u64
pub fn value_count_max_multiple() -> u64
Minimum alignment multiple that value_count_max must satisfy.
Sourcepub fn get_index<Q>(&mut self, key: &Q) -> Option<usize>
pub fn get_index<Q>(&mut self, key: &Q) -> Option<usize>
Look up a key, returning its index if found.
Sourcepub fn get<Q>(&mut self, key: &Q) -> Option<&E::Value>
pub fn get<Q>(&mut self, key: &Q) -> Option<&E::Value>
Look up a key, returning a reference to the value if found.
Sourcepub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut E::Value>
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut E::Value>
Look up a key, returning a mutable reference to the value if found.
Sourcepub fn remove<Q>(&mut self, key: &Q) -> Option<E::Value>
pub fn remove<Q>(&mut self, key: &Q) -> Option<E::Value>
Remove a key from the cache if present.
Sourcepub fn demote<Q>(&mut self, key: &Q)
pub fn demote<Q>(&mut self, key: &Q)
Hint that the key is less likely to be accessed in the future.
Sourcepub fn upsert(&mut self, value: E::Value) -> UpsertResult<E::Value>
pub fn upsert(&mut self, value: E::Value) -> UpsertResult<E::Value>
Upsert a value, evicting an older entry if needed.
Trait Implementations§
Source§impl<E: KeyExtract, S: BuildHasher, L: CacheLayout, A: Allocator> Drop for SetAssociativeCache<E, S, L, A>
impl<E: KeyExtract, S: BuildHasher, L: CacheLayout, A: Allocator> Drop for SetAssociativeCache<E, S, L, A>
Auto Trait Implementations§
impl<E, S, L, A> Freeze for SetAssociativeCache<E, S, L, A>
impl<E, S, L, A> RefUnwindSafe for SetAssociativeCache<E, S, L, A>where
S: RefUnwindSafe,
A: RefUnwindSafe,
E: RefUnwindSafe,
L: RefUnwindSafe,
<E as KeyExtract>::Value: RefUnwindSafe,
impl<E, S, L, A = Global> !Send for SetAssociativeCache<E, S, L, A>
impl<E, S, L, A = Global> !Sync for SetAssociativeCache<E, S, L, A>
impl<E, S, L, A> Unpin for SetAssociativeCache<E, S, L, A>
impl<E, S, L, A> UnsafeUnpin for SetAssociativeCache<E, S, L, A>where
S: UnsafeUnpin,
A: UnsafeUnpin,
impl<E, S, L, A> UnwindSafe for SetAssociativeCache<E, S, L, A>where
S: UnwindSafe,
A: UnwindSafe,
E: UnwindSafe,
L: UnwindSafe,
<E as KeyExtract>::Value: 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