pub struct LruCacheConfig { /* private fields */ }
Expand description
Configuration for an LRU (Least Recently Used) cache.
LRU evicts the least recently accessed items when the cache reaches capacity.
§Examples
use cache_rs::config::lru::LruCacheConfig;
use core::num::NonZeroUsize;
// Create a config with capacity of 100 items
let config = LruCacheConfig::new(NonZeroUsize::new(100).unwrap());
assert_eq!(config.capacity(), NonZeroUsize::new(100).unwrap());
Implementations§
Source§impl LruCacheConfig
impl LruCacheConfig
Sourcepub fn new(capacity: NonZeroUsize) -> Self
pub fn new(capacity: NonZeroUsize) -> Self
Creates a new configuration for an LRU 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 LruCacheConfig
impl Clone for LruCacheConfig
Source§fn clone(&self) -> LruCacheConfig
fn clone(&self) -> LruCacheConfig
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 LruCacheConfig
impl Debug for LruCacheConfig
impl Copy for LruCacheConfig
Auto Trait Implementations§
impl Freeze for LruCacheConfig
impl RefUnwindSafe for LruCacheConfig
impl Send for LruCacheConfig
impl Sync for LruCacheConfig
impl Unpin for LruCacheConfig
impl UnwindSafe for LruCacheConfig
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