pub struct NegCache { /* private fields */ }Expand description
Thread-safe negative result cache.
Keys are (query_fingerprint, content_hash) pairs. When a file is verified
and produces zero matches, it is recorded here so subsequent queries for the
same pattern can skip re-reading the file if its content hasn’t changed.
Implementations§
Source§impl NegCache
impl NegCache
Sourcepub fn new(max_entries: usize) -> Self
pub fn new(max_entries: usize) -> Self
Create a negative cache with the given maximum entry count.
Sourcepub fn set_admit(&self, allow: bool)
pub fn set_admit(&self, allow: bool)
Set whether new entries are admitted.
When false, record_negative returns immediately without caching.
Lookups still work on existing entries.
§Panics
Panics if the internal RwLock is poisoned.
Sourcepub fn is_known_negative(
&self,
query_fingerprint: u64,
content_hash: u64,
) -> bool
pub fn is_known_negative( &self, query_fingerprint: u64, content_hash: u64, ) -> bool
§Panics
Panics if the internal RwLock is poisoned.
Sourcepub fn record_negative(&self, query_fingerprint: u64, content_hash: u64)
pub fn record_negative(&self, query_fingerprint: u64, content_hash: u64)
§Panics
Panics if the internal RwLock is poisoned.
Sourcepub fn invalidate_file(&self, content_hash: u64)
pub fn invalidate_file(&self, content_hash: u64)
§Panics
Panics if the internal RwLock is poisoned.
Sourcepub fn invalidate_query(&self, query_fingerprint: u64)
pub fn invalidate_query(&self, query_fingerprint: u64)
§Panics
Panics if the internal RwLock is poisoned.
Sourcepub fn evict_fraction(&self, fraction: f64)
pub fn evict_fraction(&self, fraction: f64)
Evict a fraction of entries (e.g., 0.5 evicts half). Used by adaptive cache policy under memory pressure.
§Panics
Panics if the internal RwLock is poisoned.
Sourcepub fn stats(&self) -> NegCacheStats
pub fn stats(&self) -> NegCacheStats
§Panics
Panics if the internal RwLock is poisoned.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for NegCache
impl RefUnwindSafe for NegCache
impl Send for NegCache
impl Sync for NegCache
impl Unpin for NegCache
impl UnsafeUnpin for NegCache
impl UnwindSafe for NegCache
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
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>
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>
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