pub trait CacheMetrics:
Send
+ Sync
+ 'static {
// Required methods
fn record_hit(&self, key: &str, tier: CacheTier);
fn record_miss(&self, key: &str);
fn record_stale_hit(&self, key: &str);
fn record_latency(&self, operation: CacheOperation, duration: Duration);
fn record_eviction(&self, reason: EvictionReason);
fn record_size(&self, size: usize, memory_bytes: usize);
}Expand description
Trait for cache metrics/observability
Implement this to integrate with your metrics system (Prometheus, StatsD, etc.)
Required Methods§
Sourcefn record_hit(&self, key: &str, tier: CacheTier)
fn record_hit(&self, key: &str, tier: CacheTier)
Record a cache hit
Sourcefn record_miss(&self, key: &str)
fn record_miss(&self, key: &str)
Record a cache miss
Sourcefn record_stale_hit(&self, key: &str)
fn record_stale_hit(&self, key: &str)
Record a stale hit (served stale while revalidating)
Sourcefn record_latency(&self, operation: CacheOperation, duration: Duration)
fn record_latency(&self, operation: CacheOperation, duration: Duration)
Record operation latency
Sourcefn record_eviction(&self, reason: EvictionReason)
fn record_eviction(&self, reason: EvictionReason)
Record an eviction
Sourcefn record_size(&self, size: usize, memory_bytes: usize)
fn record_size(&self, size: usize, memory_bytes: usize)
Record cache size