#[non_exhaustive]pub struct MemorySettings {
pub purge_interval_secs: Option<u64>,
pub max_entries: Option<usize>,
pub shards: Option<usize>,
}memory only.Expand description
The memory store’s own settings, apart from the shared ones. A hybrid store’s local layer
takes these too, under local.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.purge_interval_secs: Option<u64>How often the store drops its expired entries: 60 seconds by default. None turns that
off, for an application that calls purge itself; validate rejects 0.
max_entries: Option<usize>The most entries the store holds. Past it, an insert starts a trim that drops expired
entries, then the least recently used, down to about nine tenths of the limit. Inside a
tokio runtime the trim runs on the blocking pool and inserts go on meanwhile, so the store
can go over the limit while it runs; if they left it over, the trim runs again. None, the
default, sets no limit; validate rejects 0.
shards: Option<usize>How many maps the entries are split over, each with its own lock: 16 by default. More maps
let threads using different keys run side by side, and a remove_prefix, purge or trim
holds up one map at a time instead of the whole store; each call then hashes its key once
more. None means one map, a little faster for a store used from one thread; validate
rejects 0 and more than 1,024.
Implementations§
Source§impl MemorySettings
impl MemorySettings
Sourcepub fn validate(&self) -> Result<(), CacheError>
pub fn validate(&self) -> Result<(), CacheError>
Fails when a setting is 0, purge_interval_secs is over 365 days or shards is over
1,024.
Sourcepub fn purge_interval(&self) -> Option<Duration>
pub fn purge_interval(&self) -> Option<Duration>
purge_interval_secs as a Duration, or None when the store doesn’t purge by itself.
Trait Implementations§
Source§impl Clone for MemorySettings
impl Clone for MemorySettings
Source§fn clone(&self) -> MemorySettings
fn clone(&self) -> MemorySettings
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more