#[non_exhaustive]pub struct CacheSettings {
pub default_ttl_secs: Option<u64>,
pub refresh_threshold: Option<f64>,
pub lock_timeout_ms: Option<u64>,
}Expand description
Settings every store has. Each store’s settings flatten them, so in a config file they sit
beside the store’s own: { "default_ttl_secs": 300, "max_entries": 10000 }.
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.default_ttl_secs: Option<u64>The TTL of a write that doesn’t set one: none by default. None keeps values until
removed or evicted; validate rejects 0, which would expire every write at once.
refresh_threshold: Option<f64>The share of an entry’s TTL after which get_or_set reloads it ahead of expiry, such as
0.8: off by default. None turns refresh-ahead off; validate rejects a value outside
(0, 1).
lock_timeout_ms: Option<u64>How long get_or_set waits for another caller’s load of the same key before it loads the
value itself: 30 seconds by default. None waits until that load finishes, so a loader
that hangs holds up every caller of its key for as long. validate rejects 0, which
would let every caller load at once.
Implementations§
Source§impl CacheSettings
impl CacheSettings
Sourcepub fn validate(&self) -> Result<(), CacheError>
pub fn validate(&self) -> Result<(), CacheError>
Fails when default_ttl_secs or lock_timeout_ms is 0 or over MAX_TTL_SECS, or
refresh_threshold is not between 0 and 1.
Sourcepub fn default_ttl(&self) -> Option<Duration>
pub fn default_ttl(&self) -> Option<Duration>
default_ttl_secs as a Duration, or None when a write without a TTL never expires.
Sourcepub fn lock_timeout(&self) -> Option<Duration>
pub fn lock_timeout(&self) -> Option<Duration>
lock_timeout_ms as a Duration, or None to wait as long as the other load takes.
Trait Implementations§
Source§impl Clone for CacheSettings
impl Clone for CacheSettings
Source§fn clone(&self) -> CacheSettings
fn clone(&self) -> CacheSettings
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more