pub struct CacheMetrics { /* private fields */ }Expand description
Metrics collector for cache operations
Implementations§
Source§impl CacheMetrics
impl CacheMetrics
Sourcepub fn record_operation(&self, tier: CacheTier, operation: CacheOperation)
pub fn record_operation(&self, tier: CacheTier, operation: CacheOperation)
Record a cache operation
Sourcepub fn record_latency(&self, tier: CacheTier, duration: Duration)
pub fn record_latency(&self, tier: CacheTier, duration: Duration)
Record cache lookup latency
Sourcepub fn record_request(&self)
pub fn record_request(&self)
Record a request (for overall metrics)
Sourcepub fn update_cache_size(&self, tier: CacheTier, size: u64)
pub fn update_cache_size(&self, tier: CacheTier, size: u64)
Update cache size gauge
Sourcepub fn update_cache_memory(&self, tier: CacheTier, bytes: u64)
pub fn update_cache_memory(&self, tier: CacheTier, bytes: u64)
Update cache memory usage
Sourcepub fn l1_hit_rate(&self) -> f64
pub fn l1_hit_rate(&self) -> f64
Calculate L1 hit rate
Sourcepub fn l2_hit_rate(&self) -> f64
pub fn l2_hit_rate(&self) -> f64
Calculate L2 hit rate
Sourcepub fn overall_hit_rate(&self) -> f64
pub fn overall_hit_rate(&self) -> f64
Calculate overall cache hit rate (L1 + L2)
Sourcepub fn total_requests(&self) -> u64
pub fn total_requests(&self) -> u64
Get total number of requests
Sourcepub fn snapshot(&self) -> MetricsSnapshot
pub fn snapshot(&self) -> MetricsSnapshot
Get snapshot of current metrics
Trait Implementations§
Source§impl Clone for CacheMetrics
impl Clone for CacheMetrics
Source§fn clone(&self) -> CacheMetrics
fn clone(&self) -> CacheMetrics
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CacheMetrics
impl Debug for CacheMetrics
Auto Trait Implementations§
impl Freeze for CacheMetrics
impl RefUnwindSafe for CacheMetrics
impl Send for CacheMetrics
impl Sync for CacheMetrics
impl Unpin for CacheMetrics
impl UnwindSafe for CacheMetrics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more