pub struct GdsfCacheConfig { /* private fields */ }
Expand description
Configuration for a GDSF (Greedy Dual-Size Frequency) cache.
GDSF assigns a priority to each item based on the formula: Priority = (Frequency / Size) + Global_Age
§Examples
use cache_rs::config::gdsf::GdsfCacheConfig;
use core::num::NonZeroUsize;
// Create a config with capacity of 100 items and initial age of 0.0
let config = GdsfCacheConfig::new(NonZeroUsize::new(100).unwrap());
assert_eq!(config.capacity(), NonZeroUsize::new(100).unwrap());
assert_eq!(config.initial_age(), 0.0);
Implementations§
Source§impl GdsfCacheConfig
impl GdsfCacheConfig
Sourcepub fn new(capacity: NonZeroUsize) -> Self
pub fn new(capacity: NonZeroUsize) -> Self
Creates a new configuration for a GDSF cache with initial age of 0.0.
§Arguments
capacity
- Maximum number of key-value pairs the cache can hold
Sourcepub fn with_initial_age(capacity: NonZeroUsize, initial_age: f64) -> Self
pub fn with_initial_age(capacity: NonZeroUsize, initial_age: f64) -> Self
Creates a new configuration for a GDSF 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) -> f64
pub fn initial_age(&self) -> f64
Returns the initial global age value.
Trait Implementations§
Source§impl Clone for GdsfCacheConfig
impl Clone for GdsfCacheConfig
Source§fn clone(&self) -> GdsfCacheConfig
fn clone(&self) -> GdsfCacheConfig
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 GdsfCacheConfig
impl Debug for GdsfCacheConfig
impl Copy for GdsfCacheConfig
Auto Trait Implementations§
impl Freeze for GdsfCacheConfig
impl RefUnwindSafe for GdsfCacheConfig
impl Send for GdsfCacheConfig
impl Sync for GdsfCacheConfig
impl Unpin for GdsfCacheConfig
impl UnwindSafe for GdsfCacheConfig
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