pub struct MemoryStore<V: Clone + Send + Sync + 'static> { /* private fields */ }Expand description
The L1 memory store.
Implementations§
Source§impl<V: Clone + Send + Sync + 'static> MemoryStore<V>
impl<V: Clone + Send + Sync + 'static> MemoryStore<V>
Sourcepub fn new(max_capacity: Option<u64>, events: Events) -> Self
pub fn new(max_capacity: Option<u64>, events: Events) -> Self
Creates a store with an optional maximum entry capacity (None =
unbounded). events receives an Eviction event
whenever the backend evicts an entry for expiry or capacity (not for our
own explicit removes/updates).
Sourcepub async fn get(&self, key: &str) -> Option<Entry<V>>
pub async fn get(&self, key: &str) -> Option<Entry<V>>
Reads an entry, if present and not physically expired.
Sourcepub async fn remove(&self, key: &str) -> Option<Entry<V>>
pub async fn remove(&self, key: &str) -> Option<Entry<V>>
Removes an entry, returning the previous value if any.
Sourcepub fn invalidate_all(&self)
pub fn invalidate_all(&self)
Invalidates every entry (lazily).
Sourcepub async fn run_pending_tasks(&self)
pub async fn run_pending_tasks(&self)
Forces pending maintenance to run — primarily for deterministic tests.
Trait Implementations§
Auto Trait Implementations§
impl<V> !RefUnwindSafe for MemoryStore<V>
impl<V> !UnwindSafe for MemoryStore<V>
impl<V> Freeze for MemoryStore<V>
impl<V> Send for MemoryStore<V>
impl<V> Sync for MemoryStore<V>
impl<V> Unpin for MemoryStore<V>
impl<V> UnsafeUnpin for MemoryStore<V>
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