pub struct MemCache { /* private fields */ }Expand description
Byte-weighted, TTL’d LRU over CachedScan values.
Shared by the MCP server and the CLI so the bound is written once — the duplication of this cache is what MCP-05 and CLI-08 have in common.
Implementations§
Source§impl MemCache
impl MemCache
Sourcepub fn get(&self, key: &str) -> Option<Arc<CachedScan>>
pub fn get(&self, key: &str) -> Option<Arc<CachedScan>>
Look up key, refreshing its recency. An entry older than the TTL
is removed and reported as a miss.
Sourcepub fn put(&self, key: &str, scan: CachedScan) -> Arc<CachedScan> ⓘ
pub fn put(&self, key: &str, scan: CachedScan) -> Arc<CachedScan> ⓘ
Insert (or replace) key, then evict least-recently-used entries
until the total is within budget.
Returns the stored value so the caller can use it whether or not it was retained: an entry bigger than the whole budget is served but not kept.
Sourcepub fn put_arc(&self, key: &str, scan: Arc<CachedScan>) -> Arc<CachedScan> ⓘ
pub fn put_arc(&self, key: &str, scan: Arc<CachedScan>) -> Arc<CachedScan> ⓘ
MemCache::put for a value the caller already shares.
Sourcepub fn sweep_expired(&self) -> u64
pub fn sweep_expired(&self) -> u64
Drop every entry older than the TTL. get does this lazily; this is
for a caller that wants the bytes back without a lookup.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MemCache
impl RefUnwindSafe for MemCache
impl Send for MemCache
impl Sync for MemCache
impl Unpin for MemCache
impl UnsafeUnpin for MemCache
impl UnwindSafe for MemCache
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> 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