#[non_exhaustive]pub struct CacheStats {
pub hits: u64,
pub misses: u64,
pub hit_ratio: f64,
}Expand description
Snapshot of a Config’s cache-hit / cache-miss counters.
Returned by Config::cache_stats. The struct is #[non_exhaustive]
so the v1.x SemVer contract can add new counter fields (e.g.
evictions, insertions, per-shard breakdowns) in MINOR releases
without breaking user code.
§Stability note for v0.9.5
In v0.9.5 every CacheStats returned by Config::cache_stats
has hits = 0, misses = 0, hit_ratio = 0.0. The lock-free
cache layer that populates these counters lands in a follow-up
v0.9.5 implementation release. The struct is shipping now so the
API surface is locked in ahead of the implementation.
§Examples
use config_lib::Config;
let cfg = Config::new();
let stats = cfg.cache_stats();
assert_eq!(stats.hits, 0);
assert_eq!(stats.misses, 0);
assert_eq!(stats.hit_ratio, 0.0);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.hits: u64Number of cache lookups that resolved to a cached value.
misses: u64Number of cache lookups that did not find a cached value and fell through to the canonical storage.
hit_ratio: f64hits / (hits + misses) as an f64 in [0.0, 1.0]. Returns
0.0 when no lookups have happened yet.
Trait Implementations§
Source§impl Clone for CacheStats
impl Clone for CacheStats
Source§fn clone(&self) -> CacheStats
fn clone(&self) -> CacheStats
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more