pub struct CacheStats {
pub hit_count: u64,
pub miss_count: u64,
pub insert_count: u64,
pub evict_count: u64,
/* private fields */
}Expand description
Statistics collected by a ClawCache instance.
Retrieve via crate::ClawEngine::cache_stats.
§Example
use claw_core::CacheStats;
let stats = CacheStats::new();
assert_eq!(stats.hit_ratio(), 0.0);Fields§
§hit_count: u64Number of cache lookups that found an entry.
miss_count: u64Number of cache lookups that found no entry.
insert_count: u64Total number of entries inserted into the cache.
evict_count: u64Total number of entries evicted from the cache.
Implementations§
Source§impl CacheStats
impl CacheStats
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a zeroed CacheStats.
§Example
use claw_core::CacheStats;
let s = CacheStats::new();
assert_eq!(s.hit_count, 0);Sourcepub fn rolling_hit_rate(&self) -> f64
pub fn rolling_hit_rate(&self) -> f64
Cache hit rate over the most recent 1 000 lookups (0.0 – 1.0).
Returns 0.0 when fewer than one lookup has been recorded.
Trait Implementations§
Source§impl Clone for CacheStats
impl Clone for CacheStats
Source§fn clone(&self) -> CacheStats
fn clone(&self) -> CacheStats
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 CacheStats
impl Debug for CacheStats
Source§impl Default for CacheStats
impl Default for CacheStats
Source§fn default() -> CacheStats
fn default() -> CacheStats
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CacheStats
impl RefUnwindSafe for CacheStats
impl Send for CacheStats
impl Sync for CacheStats
impl Unpin for CacheStats
impl UnsafeUnpin for CacheStats
impl UnwindSafe for CacheStats
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