pub struct MemoryCache { /* private fields */ }Expand description
In-memory cache implementation
Implementations§
Trait Implementations§
Source§impl Cache for MemoryCache
impl Cache for MemoryCache
Source§fn set<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
key: &'life1 str,
value: &'life2 T,
ttl_seconds: Option<u64>,
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
fn set<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, key: &'life1 str, value: &'life2 T, ttl_seconds: Option<u64>, ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
Store value in cache
Source§fn get<'life0, 'life1, 'async_trait, T>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = CacheResult<Option<T>>> + Send + 'async_trait>>where
T: for<'de> Deserialize<'de> + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait, T>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = CacheResult<Option<T>>> + Send + 'async_trait>>where
T: for<'de> Deserialize<'de> + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get value from cache
Source§fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = CacheResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = CacheResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete value from cache
Source§fn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = CacheResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = CacheResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if key exists in cache
Source§fn expire<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
ttl_seconds: u64,
) -> Pin<Box<dyn Future<Output = CacheResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn expire<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
ttl_seconds: u64,
) -> Pin<Box<dyn Future<Output = CacheResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Set TTL for existing key
Source§fn ttl<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = CacheResult<Option<u64>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn ttl<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = CacheResult<Option<u64>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get TTL for key (None if key doesn’t exist or has no expiration)
Source§fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Clear all cache entries
Source§fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CacheResult<CacheStats>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CacheResult<CacheStats>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get cache statistics
Source§fn mget<'life0, 'async_trait, T>(
&'life0 self,
keys: Vec<String>,
) -> Pin<Box<dyn Future<Output = CacheResult<Vec<(String, Option<T>)>>> + Send + 'async_trait>>where
T: for<'de> Deserialize<'de> + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
fn mget<'life0, 'async_trait, T>(
&'life0 self,
keys: Vec<String>,
) -> Pin<Box<dyn Future<Output = CacheResult<Vec<(String, Option<T>)>>> + Send + 'async_trait>>where
T: for<'de> Deserialize<'de> + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
Get multiple values from cache
Auto Trait Implementations§
impl !RefUnwindSafe for MemoryCache
impl !UnwindSafe for MemoryCache
impl Freeze for MemoryCache
impl Send for MemoryCache
impl Sync for MemoryCache
impl Unpin for MemoryCache
impl UnsafeUnpin for MemoryCache
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