pub struct RedisCache { /* private fields */ }Expand description
Redis cache implementation
Implementations§
Source§impl RedisCache
impl RedisCache
Sourcepub async fn new(redis_url: &str) -> CacheResult<Self>
pub async fn new(redis_url: &str) -> CacheResult<Self>
Create new Redis cache
Sourcepub async fn with_config(
redis_url: &str,
key_prefix: Option<String>,
) -> CacheResult<Self>
pub async fn with_config( redis_url: &str, key_prefix: Option<String>, ) -> CacheResult<Self>
Create Redis cache with configuration
Trait Implementations§
Source§impl Cache for RedisCache
impl Cache for RedisCache
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 RedisCache
impl !UnwindSafe for RedisCache
impl Freeze for RedisCache
impl Send for RedisCache
impl Sync for RedisCache
impl Unpin for RedisCache
impl UnsafeUnpin for RedisCache
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