Skip to main content

Module stats

Module stats 

Source
Expand description

Cache statistics: hit-rate tracking and JSON export.

CacheStats records hits and misses in an atomic-friendly manner and derives the hit rate on demand. A JSON snapshot can be exported via to_json() without any external serialisation dependency.

§Example

use oximedia_cache::stats::CacheStats;

let mut stats = CacheStats::new();
stats.record_hit();
stats.record_hit();
stats.record_miss();
assert!((stats.hit_rate() - 2.0 / 3.0).abs() < 1e-6);
let json = stats.to_json();
assert!(json.contains("\"hits\":2"));

Structs§

CacheStats
Accumulates cache hit/miss counters and produces derived statistics.