pub struct AsyncRedisCache<K, V> { /* private fields */ }Available on crate feature
async and crate feature redis_store and (crate features redis_async_std or redis_tokio) only.Expand description
Cache store backed by redis
Values have a ttl applied and enforced by redis.
Uses a redis::aio::MultiplexedConnection or redis::aio::ConnectionManager
under the hood depending on if feature redis_connection_manager is used or not.
Implementations§
source§impl<K, V> AsyncRedisCache<K, V>
impl<K, V> AsyncRedisCache<K, V>
sourcepub fn new<S: ToString>(
prefix: S,
seconds: Option<u64>,
) -> AsyncRedisCacheBuilder<K, V>
pub fn new<S: ToString>( prefix: S, seconds: Option<u64>, ) -> AsyncRedisCacheBuilder<K, V>
Initialize an AsyncRedisCacheBuilder
sourcepub fn connection_string(&self) -> String
pub fn connection_string(&self) -> String
Return the redis connection string used
Trait Implementations§
source§impl<K, V> IOKashAsync<K, V> for AsyncRedisCache<K, V>
impl<K, V> IOKashAsync<K, V> for AsyncRedisCache<K, V>
source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = Result<Option<V>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Available on crate feature async only.
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = Result<Option<V>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
async only.Get a cached value
source§fn set<'life0, 'async_trait>(
&'life0 self,
key: K,
val: V,
) -> Pin<Box<dyn Future<Output = Result<Option<V>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Available on crate feature async only.
fn set<'life0, 'async_trait>(
&'life0 self,
key: K,
val: V,
) -> Pin<Box<dyn Future<Output = Result<Option<V>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
async only.Set a cached value
source§fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = Result<Option<V>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Available on crate feature async only.
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = Result<Option<V>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
async only.Remove a cached value
source§fn ttl(&self) -> Option<u64>
Available on crate feature async only.
fn ttl(&self) -> Option<u64>
async only.Return the ttl of cached values (time to eviction)
source§fn set_ttl(&mut self, seconds: u64) -> Option<u64>
Available on crate feature async only.
fn set_ttl(&mut self, seconds: u64) -> Option<u64>
async only.Set the ttl of cached values, returns the old value
source§type Error = RedisCacheError
type Error = RedisCacheError
Available on crate feature
async only.Auto Trait Implementations§
impl<K, V> Freeze for AsyncRedisCache<K, V>
impl<K, V> !RefUnwindSafe for AsyncRedisCache<K, V>
impl<K, V> Send for AsyncRedisCache<K, V>
impl<K, V> Sync for AsyncRedisCache<K, V>
impl<K, V> Unpin for AsyncRedisCache<K, V>
impl<K, V> !UnwindSafe for AsyncRedisCache<K, V>
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