pub struct SlruCacheConfig { /* private fields */ }Expand description
Configuration for an SLRU (Segmented LRU) cache.
SLRU divides the cache into two segments: a probationary segment for new entries and a protected segment for frequently accessed entries.
§Examples
use cache_rs::config::slru::SlruCacheConfig;
use core::num::NonZeroUsize;
// Create a config with total capacity of 4 items and protected capacity of 2 items
let config = SlruCacheConfig::new(
NonZeroUsize::new(4).unwrap(),
NonZeroUsize::new(2).unwrap()
);
assert_eq!(config.capacity(), NonZeroUsize::new(4).unwrap());
assert_eq!(config.protected_capacity(), NonZeroUsize::new(2).unwrap());Implementations§
Source§impl SlruCacheConfig
impl SlruCacheConfig
Sourcepub fn new(capacity: NonZeroUsize, protected_capacity: NonZeroUsize) -> Self
pub fn new(capacity: NonZeroUsize, protected_capacity: NonZeroUsize) -> Self
Sourcepub fn capacity(&self) -> NonZeroUsize
pub fn capacity(&self) -> NonZeroUsize
Returns the maximum number of key-value pairs the cache can hold.
Sourcepub fn protected_capacity(&self) -> NonZeroUsize
pub fn protected_capacity(&self) -> NonZeroUsize
Returns the maximum size of the protected segment.
Trait Implementations§
Source§impl Clone for SlruCacheConfig
impl Clone for SlruCacheConfig
Source§fn clone(&self) -> SlruCacheConfig
fn clone(&self) -> SlruCacheConfig
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 SlruCacheConfig
impl Debug for SlruCacheConfig
impl Copy for SlruCacheConfig
Auto Trait Implementations§
impl Freeze for SlruCacheConfig
impl RefUnwindSafe for SlruCacheConfig
impl Send for SlruCacheConfig
impl Sync for SlruCacheConfig
impl Unpin for SlruCacheConfig
impl UnwindSafe for SlruCacheConfig
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