pub struct S3FifoCache<K, V, S = RandomState> { /* private fields */ }Expand description
A sharded, weighted, thread-safe S3-FIFO cache backed directly by
quick_cache.
Implementations§
Source§impl<K, V, S> S3FifoCache<K, V, S>
impl<K, V, S> S3FifoCache<K, V, S>
Sourcepub const DEFAULT_SHARDS: usize = 256
pub const DEFAULT_SHARDS: usize = 256
Default power-of-two shard count used by S3FifoCache::new.
Source§impl<K, V> S3FifoCache<K, V, RandomState>
impl<K, V> S3FifoCache<K, V, RandomState>
Sourcepub fn new(total_capacity_bytes: usize) -> Self
pub fn new(total_capacity_bytes: usize) -> Self
Creates a cache with Self::DEFAULT_SHARDS shards.
Sourcepub fn with_shards(total_capacity_bytes: usize, num_shards: usize) -> Self
pub fn with_shards(total_capacity_bytes: usize, num_shards: usize) -> Self
Creates a cache with an explicit shard count.
§Panics
Panics if num_shards == 0 or if num_shards is not a power of two.
Source§impl<K, V, S> S3FifoCache<K, V, S>
impl<K, V, S> S3FifoCache<K, V, S>
Sourcepub fn with_hasher(
total_capacity_bytes: usize,
num_shards: usize,
hash_builder: S,
) -> Self
pub fn with_hasher( total_capacity_bytes: usize, num_shards: usize, hash_builder: S, ) -> Self
Creates a cache with an explicit shard count and hash builder.
Because quick_cache uses equal-capacity shards internally, the actual
backend capacity may round up when total_capacity_bytes is not evenly
divisible by num_shards.
§Panics
Panics if num_shards == 0 or if num_shards is not a power of two.
Sourcepub fn remove(&self, key: &K) -> Option<V>
pub fn remove(&self, key: &K) -> Option<V>
Removes key if present and returns the removed value.
Sourcepub fn remove_if<F>(&self, predicate: F)
pub fn remove_if<F>(&self, predicate: F)
Removes all entries matching predicate and returns the number removed.
Sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
Returns true if key is currently present.
Sourcepub fn total_charge(&self) -> usize
pub fn total_charge(&self) -> usize
Returns the current total weighted charge.
Sourcepub fn total_capacity(&self) -> usize
pub fn total_capacity(&self) -> usize
Returns the backend’s configured total weighted capacity.
This may be larger than the requested constructor argument when the requested total capacity is not evenly divisible across shards.
Sourcepub fn shard_count(&self) -> usize
pub fn shard_count(&self) -> usize
Returns the number of backend shards.
Trait Implementations§
Source§impl<K, V, S> BufferCache<K, V> for S3FifoCache<K, V, S>
impl<K, V, S> BufferCache<K, V> for S3FifoCache<K, V, S>
Source§fn strategy(&self) -> BufferCacheStrategy
fn strategy(&self) -> BufferCacheStrategy
Source§fn remove(&self, key: &K) -> Option<V>
fn remove(&self, key: &K) -> Option<V>
key if it is present and returns the removed value.Source§fn remove_if(&self, predicate: &dyn Fn(&K) -> bool)
fn remove_if(&self, predicate: &dyn Fn(&K) -> bool)
predicate.Source§fn contains_key(&self, key: &K) -> bool
fn contains_key(&self, key: &K) -> bool
true if key is currently resident.