pub struct MemoryCacheManager { /* private fields */ }Expand description
A Memory-based implementation of the CacheManager trait using Moka.
Implementations§
Source§impl MemoryCacheManager
impl MemoryCacheManager
Sourcepub fn new(prefix: String, options: MemoryCacheOptions) -> Self
pub fn new(prefix: String, options: MemoryCacheOptions) -> Self
Creates a new Memory cache manager with Moka configuration.
Source§impl MemoryCacheManager
impl MemoryCacheManager
Sourcepub async fn get_many(&mut self, keys: &[&str]) -> Result<Vec<Option<String>>>
pub async fn get_many(&mut self, keys: &[&str]) -> Result<Vec<Option<String>>>
Get multiple keys at once.
Sourcepub async fn set_many(
&mut self,
pairs: &[(&str, &str)],
_ttl_seconds: u64,
) -> Result<()>
pub async fn set_many( &mut self, pairs: &[(&str, &str)], _ttl_seconds: u64, ) -> Result<()>
Set multiple key-value pairs at once.
Sourcepub async fn get_all_entries(&self) -> Vec<(String, String, Option<Duration>)>
pub async fn get_all_entries(&self) -> Vec<(String, String, Option<Duration>)>
Get all entries from the cache as (key, value, ttl) tuples. Returns entries without the prefix.
Note: Moka doesn’t support per-entry TTL tracking, so this returns the cache’s default TTL for all entries. When syncing to another cache system, this means all entries will get the same TTL, not their remaining time.
Trait Implementations§
Source§impl CacheManager for MemoryCacheManager
impl CacheManager for MemoryCacheManager
Source§fn has<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn has<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if the given key exists in cache
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + 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<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a key from the cache
Returns None if cache does not exist
Source§fn set<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: &'life2 str,
_ttl_seconds: u64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn set<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: &'life2 str,
_ttl_seconds: u64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Set or overwrite the value in the cache
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 a key from the cache
Source§fn disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Disconnect the manager’s made connections
fn ttl<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Duration>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§impl Clone for MemoryCacheManager
impl Clone for MemoryCacheManager
Source§fn clone(&self) -> MemoryCacheManager
fn clone(&self) -> MemoryCacheManager
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 moreAuto Trait Implementations§
impl Freeze for MemoryCacheManager
impl !RefUnwindSafe for MemoryCacheManager
impl Send for MemoryCacheManager
impl Sync for MemoryCacheManager
impl Unpin for MemoryCacheManager
impl UnsafeUnpin for MemoryCacheManager
impl !UnwindSafe for MemoryCacheManager
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