CacheMetrics

Trait CacheMetrics 

Source
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§

Source

fn record_hit(&self, key: &str, tier: CacheTier)

Record a cache hit

Source

fn record_miss(&self, key: &str)

Record a cache miss

Source

fn record_stale_hit(&self, key: &str)

Record a stale hit (served stale while revalidating)

Source

fn record_latency(&self, operation: CacheOperation, duration: Duration)

Record operation latency

Source

fn record_eviction(&self, reason: EvictionReason)

Record an eviction

Source

fn record_size(&self, size: usize, memory_bytes: usize)

Record cache size

Implementors§