pub struct MokaCache { /* private fields */ }Expand description
Moka in-memory cache with per-key TTL support
This is the default L1 (hot tier) cache backend, providing:
- Fast in-memory access (< 1ms latency)
- Automatic eviction via LRU
- Per-key TTL support
- Statistics tracking
Implementations§
Trait Implementations§
Source§impl CacheBackend for MokaCache
Implement CacheBackend trait for MokaCache
impl CacheBackend for MokaCache
Implement CacheBackend trait for MokaCache
This allows MokaCache to be used as a pluggable backend in the multi-tier cache system.
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<Value>> + 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 = Option<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get value from cache by key Read more
Source§fn set_with_ttl<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Value,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_with_ttl<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Value,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Set value in cache with time-to-live Read more
Source§fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Remove value from cache Read more
Auto Trait Implementations§
impl Freeze for MokaCache
impl !RefUnwindSafe for MokaCache
impl Send for MokaCache
impl Sync for MokaCache
impl Unpin for MokaCache
impl !UnwindSafe for MokaCache
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more