pub struct SlruMeta {
pub segment: SlruSegment,
}Expand description
Metadata for SLRU (Segmented LRU) cache entries.
SLRU uses two segments to provide scan resistance:
- New items enter the probationary segment
- Accessed items in probationary are promoted to protected
- When protected is full, LRU items demote back to probationary
§Examples
use cache_rs::meta::{SlruMeta, SlruSegment};
// New entry starts in probationary
let meta = SlruMeta::default();
assert_eq!(meta.segment, SlruSegment::Probationary);
// After promotion
let protected_meta = SlruMeta::new(SlruSegment::Protected);
assert_eq!(protected_meta.segment, SlruSegment::Protected);Fields§
§segment: SlruSegmentWhich segment this entry is currently in.
Implementations§
Source§impl SlruMeta
impl SlruMeta
Sourcepub fn new(segment: SlruSegment) -> Self
pub fn new(segment: SlruSegment) -> Self
Creates a new SLRU metadata with the specified segment.
§Arguments
segment- The segment where this entry should be placed
Sourcepub fn probationary() -> Self
pub fn probationary() -> Self
Creates metadata for a probationary segment entry.
Sourcepub fn is_probationary(&self) -> bool
pub fn is_probationary(&self) -> bool
Returns true if the entry is in the probationary segment.
Sourcepub fn is_protected(&self) -> bool
pub fn is_protected(&self) -> bool
Returns true if the entry is in the protected segment.
Trait Implementations§
impl Copy for SlruMeta
impl Eq for SlruMeta
impl StructuralPartialEq for SlruMeta
Auto Trait Implementations§
impl Freeze for SlruMeta
impl RefUnwindSafe for SlruMeta
impl Send for SlruMeta
impl Sync for SlruMeta
impl Unpin for SlruMeta
impl UnwindSafe for SlruMeta
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.