pub struct MemoryCache { /* private fields */ }Expand description
A bounded in-memory LRU of verified plaintext, keyed by content_id. Bounded
by BOTH an entry count and a total-byte budget (this ends up in a wallet — no
unbounded growth). Process-trusted: a hit returns without re-verification.
Implementations§
Source§impl MemoryCache
impl MemoryCache
Sourcepub fn new(max_entries: usize, max_bytes: usize) -> Self
pub fn new(max_entries: usize, max_bytes: usize) -> Self
A cache bounded to max_entries entries and max_bytes total bytes.
Sourcepub fn get(&self, id: &str) -> Option<ResolvedData>
pub fn get(&self, id: &str) -> Option<ResolvedData>
A verified hit (bumps recency), or None.
Sourcepub fn put(&self, id: String, data: ResolvedData)
pub fn put(&self, id: String, data: ResolvedData)
Insert verified plaintext, evicting the least-recently-used entries until both bounds hold. An entry larger than the whole byte budget is simply not cached.
Auto Trait Implementations§
impl !Freeze for MemoryCache
impl !RefUnwindSafe for MemoryCache
impl !Sync for MemoryCache
impl Send for MemoryCache
impl Unpin for MemoryCache
impl UnsafeUnpin for MemoryCache
impl UnwindSafe for MemoryCache
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