pub struct MultiLayerCache<L1, L2> { /* private fields */ }Expand description
A read-through, write-through composition of an L1 and L2 cache.
L1 is typically crate::memory::MemoryCache or
[crate::moka_cache::MokaL1]; L2 is typically a distributed cache such
as a Redis backend. Order of layers fixed: L1 is consulted first.
Implementations§
Source§impl<L1, L2> MultiLayerCache<L1, L2>
impl<L1, L2> MultiLayerCache<L1, L2>
Trait Implementations§
Source§impl<L1, L2> Cache for MultiLayerCache<L1, L2>
impl<L1, L2> Cache for MultiLayerCache<L1, L2>
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Fetches a value by key.
None indicates a miss.Source§fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Vec<u8>,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Vec<u8>,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Stores a value under
key, optionally expiring after ttl.Auto Trait Implementations§
impl<L1, L2> Freeze for MultiLayerCache<L1, L2>
impl<L1, L2> RefUnwindSafe for MultiLayerCache<L1, L2>where
L1: RefUnwindSafe,
L2: RefUnwindSafe,
impl<L1, L2> Send for MultiLayerCache<L1, L2>
impl<L1, L2> Sync for MultiLayerCache<L1, L2>
impl<L1, L2> Unpin for MultiLayerCache<L1, L2>
impl<L1, L2> UnsafeUnpin for MultiLayerCache<L1, L2>where
L1: UnsafeUnpin,
L2: UnsafeUnpin,
impl<L1, L2> UnwindSafe for MultiLayerCache<L1, L2>where
L1: UnwindSafe,
L2: UnwindSafe,
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