pub struct LfudaCacheConfig { /* private fields */ }
Expand description
Configuration for an LFUDA (Least Frequently Used with Dynamic Aging) cache.
LFUDA enhances LFU by using a dynamic aging mechanism that prevents old frequently-accessed items from permanently blocking new items.
§Examples
use cache_rs::config::lfuda::LfudaCacheConfig;
use core::num::NonZeroUsize;
// Create a config with capacity of 100 items and initial age of 0
let config = LfudaCacheConfig::new(NonZeroUsize::new(100).unwrap());
assert_eq!(config.capacity(), NonZeroUsize::new(100).unwrap());
assert_eq!(config.initial_age(), 0);
Implementations§
Source§impl LfudaCacheConfig
impl LfudaCacheConfig
Sourcepub fn new(capacity: NonZeroUsize) -> Self
pub fn new(capacity: NonZeroUsize) -> Self
Creates a new configuration for an LFUDA cache with initial age of 0.
§Arguments
capacity
- Maximum number of key-value pairs the cache can hold
Sourcepub fn with_initial_age(capacity: NonZeroUsize, initial_age: usize) -> Self
pub fn with_initial_age(capacity: NonZeroUsize, initial_age: usize) -> Self
Creates a new configuration for an LFUDA cache with a specific initial age.
§Arguments
capacity
- Maximum number of key-value pairs the cache can holdinitial_age
- Initial global age value
Sourcepub fn capacity(&self) -> NonZeroUsize
pub fn capacity(&self) -> NonZeroUsize
Returns the maximum number of key-value pairs the cache can hold.
Sourcepub fn initial_age(&self) -> usize
pub fn initial_age(&self) -> usize
Returns the initial global age value.
Trait Implementations§
Source§impl Clone for LfudaCacheConfig
impl Clone for LfudaCacheConfig
Source§fn clone(&self) -> LfudaCacheConfig
fn clone(&self) -> LfudaCacheConfig
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 LfudaCacheConfig
impl Debug for LfudaCacheConfig
impl Copy for LfudaCacheConfig
Auto Trait Implementations§
impl Freeze for LfudaCacheConfig
impl RefUnwindSafe for LfudaCacheConfig
impl Send for LfudaCacheConfig
impl Sync for LfudaCacheConfig
impl Unpin for LfudaCacheConfig
impl UnwindSafe for LfudaCacheConfig
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