pub struct PostingCache { /* private fields */ }Expand description
Thread-safe, memory-bounded LRU cache mapping Trigram → PostingList.
Uses FIFO eviction (oldest first) when the memory_ceiling is exceeded.
Admission can be toggled via set_admit for adaptive
cache policy integration.
Implementations§
Source§impl PostingCache
impl PostingCache
Sourcepub fn new(memory_ceiling: usize) -> Self
pub fn new(memory_ceiling: usize) -> Self
Create a cache with the given byte budget (0 = reject all inserts).
Sourcepub fn set_admit(&self, allow: bool)
pub fn set_admit(&self, allow: bool)
Set whether new entries are admitted.
When false, insert returns immediately without caching.
Existing entries are retained (not evicted) — call invalidate_all to flush.
§Panics
Panics if the internal RwLock is poisoned.
Sourcepub fn get(&self, trigram: Trigram) -> Option<PostingList>
pub fn get(&self, trigram: Trigram) -> Option<PostingList>
§Panics
Panics if the internal RwLock is poisoned.
Sourcepub fn insert(&self, trigram: Trigram, list: PostingList)
pub fn insert(&self, trigram: Trigram, list: PostingList)
§Panics
Panics if the internal RwLock is poisoned.
Sourcepub fn invalidate(&self, trigram: Trigram)
pub fn invalidate(&self, trigram: Trigram)
§Panics
Panics if the internal RwLock is poisoned.
Sourcepub fn invalidate_all(&self)
pub fn invalidate_all(&self)
§Panics
Panics if the internal RwLock is poisoned.
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
§Panics
Panics if the internal RwLock is poisoned.
Sourcepub fn memory_used(&self) -> usize
pub fn memory_used(&self) -> usize
§Panics
Panics if the internal RwLock is poisoned.
Trait Implementations§
Source§impl Debug for PostingCache
impl Debug for PostingCache
Auto Trait Implementations§
impl !Freeze for PostingCache
impl RefUnwindSafe for PostingCache
impl Send for PostingCache
impl Sync for PostingCache
impl Unpin for PostingCache
impl UnsafeUnpin for PostingCache
impl UnwindSafe for PostingCache
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more