Skip to main content

Module meta

Module meta 

Source
Expand description

Algorithm-specific metadata types.

Provides metadata structures for each cache algorithm:

  • LfuMeta: Frequency counter for LFU
  • LfudaMeta: Frequency for LFUDA (age is cache-global)
  • SlruMeta: Segment location for SLRU
  • GdsfMeta: Frequency and priority for GDSF Algorithm-Specific Metadata Types

This module provides metadata types used by different cache algorithms. Each cache algorithm that needs per-entry metadata defines its own type here, which can be used with CacheEntry<K, V, M>.

§Metadata Types

AlgorithmMetadata TypeDescription
LRU() (none)Position in list is implicit
LFULfuMetaAccess frequency counter
LFUDALfudaMetaAccess frequency (age is cache-global)
SLRUSlruMetaSegment location (probationary/protected)
GDSFGdsfMetaFrequency and calculated priority

§Memory Overhead

Metadata TypeSize
()0 bytes
LfuMeta8 bytes
LfudaMeta8 bytes
SlruMeta1 byte (+ padding)
GdsfMeta16 bytes

§Usage

use cache_rs::meta::{LfuMeta, SlruSegment, SlruMeta, GdsfMeta};

// LFU metadata with initial frequency
let lfu_meta = LfuMeta::default();
assert_eq!(lfu_meta.frequency, 0);

// SLRU metadata for probationary segment
let slru_meta = SlruMeta::new(SlruSegment::Probationary);
assert_eq!(slru_meta.segment, SlruSegment::Probationary);

// GDSF metadata with initial values
let gdsf_meta = GdsfMeta::default();
assert_eq!(gdsf_meta.frequency, 0);
assert_eq!(gdsf_meta.priority, 0.0);

Structs§

GdsfMeta
Metadata for GDSF (Greedy Dual-Size Frequency) cache entries.
LfuMeta
Metadata for LFU (Least Frequently Used) cache entries.
LfudaMeta
Metadata for LFUDA (LFU with Dynamic Aging) cache entries.
SlruMeta
Metadata for SLRU (Segmented LRU) cache entries.

Enums§

SlruSegment
Segment location within an SLRU cache.