pub struct EdgeCache { /* private fields */ }Expand description
LRU + version + TTL cache. Cheap to clone via Arc.
Implementations§
Source§impl EdgeCache
impl EdgeCache
pub fn new(max_entries: usize) -> Self
Sourcepub fn next_version(&self) -> u64
pub fn next_version(&self) -> u64
Mint a fresh logical version. Used by the home when assigning version stamps to writes; also used by the cache itself when inserting locally-cached entries.
Sourcepub fn get(&self, key: &CacheKey) -> Option<CacheEntry>
pub fn get(&self, key: &CacheKey) -> Option<CacheEntry>
Look up a cache entry. Returns None on miss or expired TTL. Bumps the LRU on hit; increments hit/miss counters either way.
Sourcepub fn insert(&self, key: CacheKey, entry: CacheEntry)
pub fn insert(&self, key: CacheKey, entry: CacheEntry)
Insert / overwrite an entry. Triggers LRU eviction if over capacity.
Sourcepub fn invalidate(&self, up_to_version: u64, tables: &[String]) -> u64
pub fn invalidate(&self, up_to_version: u64, tables: &[String]) -> u64
Drop every entry whose version <= up_to_version AND whose
tables overlaps with tables (empty tables invalidates
every entry meeting the version bound). Returns the count
dropped.
pub fn stats(&self) -> EdgeCacheStats
Sourcepub fn insert_with(&self, key: CacheKey, entry: CacheEntry)
pub fn insert_with(&self, key: CacheKey, entry: CacheEntry)
Test-only: deterministic insert with explicit version + TTL.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EdgeCache
impl !RefUnwindSafe for EdgeCache
impl Send for EdgeCache
impl Sync for EdgeCache
impl Unpin for EdgeCache
impl UnsafeUnpin for EdgeCache
impl !UnwindSafe for EdgeCache
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<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