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.Source§fn total_charge(&self) -> usize
fn total_charge(&self) -> usize
Source§fn total_capacity(&self) -> usize
fn total_capacity(&self) -> usize
Source§fn shard_count(&self) -> usize
fn shard_count(&self) -> usize
Auto Trait Implementations§
impl<K, V, S = RandomState> !RefUnwindSafe for S3FifoCache<K, V, S>
impl<K, V, S = RandomState> !UnwindSafe for S3FifoCache<K, V, S>
impl<K, V, S> Forget for S3FifoCache<K, V, S>
impl<K, V, S> Freeze for S3FifoCache<K, V, S>
impl<K, V, S> Move for S3FifoCache<K, V, S>
impl<K, V, S> Send for S3FifoCache<K, V, S>
impl<K, V, S> Sync for S3FifoCache<K, V, S>
impl<K, V, S> Unpin for S3FifoCache<K, V, S>
impl<K, V, S> UnsafeUnpin for S3FifoCache<K, V, S>where
Cache<K, V, CacheEntryWeighter, S>: UnsafeUnpin,
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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