pub struct LfuCacheConfig { /* private fields */ }Expand description
Configuration for an LFU (Least Frequently Used) cache.
LFU tracks the frequency of access for each item and evicts the least frequently used items when the cache reaches capacity.
§Examples
use cache_rs::config::lfu::LfuCacheConfig;
use core::num::NonZeroUsize;
// Create a config with capacity of 100 items
let config = LfuCacheConfig::new(NonZeroUsize::new(100).unwrap());
assert_eq!(config.capacity(), NonZeroUsize::new(100).unwrap());Implementations§
Source§impl LfuCacheConfig
impl LfuCacheConfig
Sourcepub fn new(capacity: NonZeroUsize) -> Self
pub fn new(capacity: NonZeroUsize) -> Self
Creates a new configuration for an LFU cache.
§Arguments
capacity- Maximum number of key-value pairs the cache can hold
Sourcepub fn capacity(&self) -> NonZeroUsize
pub fn capacity(&self) -> NonZeroUsize
Returns the maximum number of key-value pairs the cache can hold.
Trait Implementations§
Source§impl Clone for LfuCacheConfig
impl Clone for LfuCacheConfig
Source§fn clone(&self) -> LfuCacheConfig
fn clone(&self) -> LfuCacheConfig
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 LfuCacheConfig
impl Debug for LfuCacheConfig
impl Copy for LfuCacheConfig
Auto Trait Implementations§
impl Freeze for LfuCacheConfig
impl RefUnwindSafe for LfuCacheConfig
impl Send for LfuCacheConfig
impl Sync for LfuCacheConfig
impl Unpin for LfuCacheConfig
impl UnwindSafe for LfuCacheConfig
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