pub struct LfudaCacheMetrics {
pub core: CoreCacheMetrics,
pub global_age: u64,
pub total_aging_events: u64,
pub min_priority: u64,
pub max_priority: u64,
pub total_frequency_increments: u64,
pub items_benefited_from_aging: u64,
pub total_age_distributed: u64,
}
Expand description
LFUDA-specific metrics (extends CoreCacheMetrics)
This struct contains metrics specific to the LFUDA (Least Frequently Used with Dynamic Aging) cache algorithm. LFUDA combines frequency tracking with aging to prevent old frequently-used items from blocking new items indefinitely.
Fields§
§core: CoreCacheMetrics
Core metrics common to all cache algorithms
global_age: u64
Current global age value
total_aging_events: u64
Total number of aging events (when global age is increased)
min_priority: u64
Current minimum priority in the cache
max_priority: u64
Current maximum priority in the cache
total_frequency_increments: u64
Total number of frequency increments (every cache hit increases frequency)
items_benefited_from_aging: u64
Number of items that benefited from aging (had their effective priority boosted)
total_age_distributed: u64
Total age value distributed to items at insertion time
Implementations§
Source§impl LfudaCacheMetrics
impl LfudaCacheMetrics
Sourcepub fn new(max_cache_size_bytes: u64) -> Self
pub fn new(max_cache_size_bytes: u64) -> Self
Creates a new LfudaCacheMetrics instance with the specified maximum cache size
§Arguments
max_cache_size_bytes
- The maximum allowed cache size in bytes
Sourcepub fn record_aging_event(&mut self, new_global_age: u64)
pub fn record_aging_event(&mut self, new_global_age: u64)
Records an aging event (when global age is increased due to eviction)
§Arguments
new_global_age
- The new global age value
Sourcepub fn record_frequency_increment(&mut self, new_priority: u64)
pub fn record_frequency_increment(&mut self, new_priority: u64)
Records a frequency increment (when an item is accessed and its frequency increases)
§Arguments
new_priority
- The new priority value for the accessed item
Sourcepub fn record_aging_benefit(&mut self, age_benefit: u64)
pub fn record_aging_benefit(&mut self, age_benefit: u64)
Records when an item benefits from aging (gets age boost at insertion)
§Arguments
age_benefit
- The age value added to the item’s priority
Sourcepub fn average_aging_benefit(&self) -> f64
pub fn average_aging_benefit(&self) -> f64
Calculates the average aging benefit per item
§Returns
Average age benefit per item that received aging boost, or 0.0 if none
Sourcepub fn priority_range(&self) -> u64
pub fn priority_range(&self) -> u64
Sourcepub fn aging_effectiveness(&self) -> f64
pub fn aging_effectiveness(&self) -> f64
Calculates the aging effectiveness (aging events / evictions)
§Returns
How often evictions trigger aging events, or 0.0 if no evictions
Sourcepub fn aging_contribution_ratio(&self) -> f64
pub fn aging_contribution_ratio(&self) -> f64
Calculates the frequency advantage due to aging
§Returns
How much of the total priority comes from aging vs raw frequency
Sourcepub fn to_btreemap(&self) -> BTreeMap<String, f64>
pub fn to_btreemap(&self) -> BTreeMap<String, f64>
Converts LFUDA metrics to a BTreeMap for reporting
This method returns all metrics relevant to the LFUDA cache algorithm, including both core metrics and LFUDA-specific aging and priority metrics.
Uses BTreeMap to ensure consistent, deterministic ordering of metrics.
§Returns
A BTreeMap containing all LFUDA cache metrics as key-value pairs
Trait Implementations§
Source§impl CacheMetrics for LfudaCacheMetrics
impl CacheMetrics for LfudaCacheMetrics
Source§fn metrics(&self) -> BTreeMap<String, f64>
fn metrics(&self) -> BTreeMap<String, f64>
Returns all LFUDA cache metrics as key-value pairs in deterministic order
§Returns
A BTreeMap containing all metrics tracked by this LFUDA cache instance
Source§fn algorithm_name(&self) -> &'static str
fn algorithm_name(&self) -> &'static str
Returns the algorithm name for this cache implementation
§Returns
“LFUDA” - identifying this as a Least Frequently Used with Dynamic Aging cache
Source§impl Clone for LfudaCacheMetrics
impl Clone for LfudaCacheMetrics
Source§fn clone(&self) -> LfudaCacheMetrics
fn clone(&self) -> LfudaCacheMetrics
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more