pub struct MemoryCacheRepository { /* private fields */ }Expand description
In-memory cache repository with size-based eviction.
Uses moka::future::Cache with a max-capacity bound. Expiry is
checked in-band in get — no
expire_after or time_to_live is configured on the moka cache.
Implementations§
Trait Implementations§
Source§impl CacheRepository for MemoryCacheRepository
impl CacheRepository for MemoryCacheRepository
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<CacheEntry>, CamelError>> + 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<CacheEntry>, CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve a value by key. Read more
Source§fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: CacheEntry,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + 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: CacheEntry,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Store a value with an optional TTL. Read more
Source§fn peek_stale<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<CacheEntry>, CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn peek_stale<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<CacheEntry>, CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Peek at a stale (expired but not yet evicted) entry. Read more
Source§fn invalidate<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn invalidate<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Remove a specific key from the cache.
Source§fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Remove all entries from the cache.
Source§fn stats(&self) -> CacheStats
fn stats(&self) -> CacheStats
Return current cache statistics. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for MemoryCacheRepository
impl !UnwindSafe for MemoryCacheRepository
impl Freeze for MemoryCacheRepository
impl Send for MemoryCacheRepository
impl Sync for MemoryCacheRepository
impl Unpin for MemoryCacheRepository
impl UnsafeUnpin for MemoryCacheRepository
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