pub struct L1Cache { /* private fields */ }Expand description
In-process LRU cache with per-entry TTL, backed by moka.
Used as the L1 layer in the dual-layer cache architecture.
Implementations§
Source§impl L1Cache
impl L1Cache
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new L1 cache with the given maximum entry capacity.
Sourcepub fn get(&self, key: &str) -> Option<Vec<u8>>
pub fn get(&self, key: &str) -> Option<Vec<u8>>
Retrieve cached bytes by key, or None if absent or expired.
Sourcepub fn set(&self, key: &str, value: &[u8], ttl: Duration)
pub fn set(&self, key: &str, value: &[u8], ttl: Duration)
Insert or overwrite an entry with the given TTL.
Sourcepub fn run_pending_tasks(&self)
pub fn run_pending_tasks(&self)
Drive moka’s internal eviction machinery. Useful in tests to force pending invalidations and expiry checks to complete synchronously.
Auto Trait Implementations§
impl Freeze for L1Cache
impl !RefUnwindSafe for L1Cache
impl Send for L1Cache
impl Sync for L1Cache
impl Unpin for L1Cache
impl UnsafeUnpin for L1Cache
impl !UnwindSafe for L1Cache
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