pub struct AccessTracker { /* private fields */ }Expand description
Tracks access frequency for cache keys.
Implementations§
Source§impl AccessTracker
impl AccessTracker
pub fn new(config: AutoRefreshConfig) -> Self
Sourcepub fn record_hit(&self, key: &str)
pub fn record_hit(&self, key: &str)
Records a cache hit for the given key.
Sourcepub fn hits_per_minute(&self, key: &str) -> f64
pub fn hits_per_minute(&self, key: &str) -> f64
Calculates the hit rate (hits per minute) for a key.
Sourcepub fn should_auto_refresh(&self, key: &str) -> bool
pub fn should_auto_refresh(&self, key: &str) -> bool
Returns whether the key qualifies for auto-refresh.
Sourcepub fn cleanup_stale(&self, max_age: Duration)
pub fn cleanup_stale(&self, max_age: Duration)
Removes stale tracking data that hasn’t been accessed recently.
Sourcepub fn tracked_keys(&self) -> usize
pub fn tracked_keys(&self) -> usize
Returns the number of tracked keys.
Trait Implementations§
Source§impl Clone for AccessTracker
impl Clone for AccessTracker
Source§fn clone(&self) -> AccessTracker
fn clone(&self) -> AccessTracker
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 moreAuto Trait Implementations§
impl Freeze for AccessTracker
impl !RefUnwindSafe for AccessTracker
impl Send for AccessTracker
impl Sync for AccessTracker
impl Unpin for AccessTracker
impl !UnwindSafe for AccessTracker
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