pub struct MemoryBackend { /* private fields */ }Expand description
Default in-process tier-1 cache. Arc<Mutex<HashMap<u64, CachedEntry>>> —
no async I/O, no external dependencies, identical behavior on native and
WASM.
Implementations§
Trait Implementations§
Source§impl CacheBackend for MemoryBackend
impl CacheBackend for MemoryBackend
Source§fn get<'life0, 'async_trait>(
&'life0 self,
key: u64,
) -> Pin<Box<dyn Future<Output = Option<CachedEntry>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get<'life0, 'async_trait>(
&'life0 self,
key: u64,
) -> Pin<Box<dyn Future<Output = Option<CachedEntry>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Look up an entry. Backends may return
None for “not present” OR
“present but failed to deserialize” — the resolver treats both as
cache miss and falls through to the next tier or the provider.Source§fn put<'life0, 'async_trait>(
&'life0 self,
key: u64,
entry: CachedEntry,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn put<'life0, 'async_trait>(
&'life0 self,
key: u64,
entry: CachedEntry,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Insert or replace an entry. Returns
Err only on backend storage
failure (poisoned mutex, IndexedDB transaction failure, etc.) — TTL
math happens at get time, not put.Source§fn invalidate<'life0, 'async_trait>(
&'life0 self,
key: u64,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn invalidate<'life0, 'async_trait>(
&'life0 self,
key: u64,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Remove a single entry. No-op if the key is absent.
Source§fn invalidate_by_tag<'life0, 'life1, 'async_trait>(
&'life0 self,
tag: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn invalidate_by_tag<'life0, 'life1, 'async_trait>(
&'life0 self,
tag: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Remove every entry whose
tags contain the given tag. Used by the
resolver’s invalidate_by_slug / invalidate_by_namespace APIs.Source§impl Clone for MemoryBackend
impl Clone for MemoryBackend
Source§fn clone(&self) -> MemoryBackend
fn clone(&self) -> MemoryBackend
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MemoryBackend
impl Debug for MemoryBackend
Source§impl Default for MemoryBackend
impl Default for MemoryBackend
Source§fn default() -> MemoryBackend
fn default() -> MemoryBackend
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MemoryBackend
impl RefUnwindSafe for MemoryBackend
impl Send for MemoryBackend
impl Sync for MemoryBackend
impl Unpin for MemoryBackend
impl UnsafeUnpin for MemoryBackend
impl UnwindSafe for MemoryBackend
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