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 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: AsRef<str>>(
prefix: S,
seconds: u64,
) -> AsyncRedisCacheBuilder<K, V>
pub fn new<S: AsRef<str>>( prefix: S, seconds: 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> IOCachedAsync<K, V> for AsyncRedisCache<K, V>
impl<K, V> IOCachedAsync<K, V> for AsyncRedisCache<K, V>
Source§fn cache_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 cache_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 cache_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 cache_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 cache_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 cache_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 cache_set_refresh(&mut self, refresh: bool) -> bool
Available on crate feature async
only.
fn cache_set_refresh(&mut self, refresh: bool) -> bool
async
only.Set the flag to control whether cache hits refresh the ttl of cached values, returns the old flag value
Source§fn cache_lifespan(&self) -> Option<u64>
Available on crate feature async
only.
fn cache_lifespan(&self) -> Option<u64>
async
only.Return the lifespan of cached values (time to eviction)
Source§fn cache_set_lifespan(&mut self, seconds: u64) -> Option<u64>
Available on crate feature async
only.
fn cache_set_lifespan(&mut self, seconds: u64) -> Option<u64>
async
only.Set the lifespan 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