Struct LfudaCacheMetrics

Source
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

Source

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
Source

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
Source

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
Source

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
Source

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

Source

pub fn priority_range(&self) -> u64

Calculates the priority range (max - min)

§Returns

The range of priorities currently in the cache

Source

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

Source

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

Source

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

Source§

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

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

Source§

fn clone(&self) -> LfudaCacheMetrics

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LfudaCacheMetrics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.