pub struct RedisCache<'a> {
pub client: Cow<'a, Client>,
}Expand description
A cache implementation that uses a Redis instance to automatically remove the cache entries when their expiration date has passed.
Fields§
§client: Cow<'a, Client>Implementations§
Trait Implementations§
Source§impl<'a, ErrorT: Error + Sync + Send + Debug> CacheHandler<ErrorT> for RedisCache<'a>
impl<'a, ErrorT: Error + Sync + Send + Debug> CacheHandler<ErrorT> for RedisCache<'a>
type CachingError = RedisError
Source§fn try_get_cache<'life0, 'life1, 'async_trait, T>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Packet<T>>, Error<ErrorT, Self::CachingError>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Serialize,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn try_get_cache<'life0, 'life1, 'async_trait, T>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Packet<T>>, Error<ErrorT, Self::CachingError>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Serialize,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
A method to implement to get a value from the cache
It should NOT return an error if the value is not in the cache
If the value is not in the cache, it should return Ok(None)
Source§fn cache_value<'life0, 'life1, 'async_trait, T>(
&'life0 self,
key: &'life1 str,
value: SuccessPacket<T>,
) -> Pin<Box<dyn Future<Output = Result<(), Error<ErrorT, Self::CachingError>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Serialize + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn cache_value<'life0, 'life1, 'async_trait, T>(
&'life0 self,
key: &'life1 str,
value: SuccessPacket<T>,
) -> Pin<Box<dyn Future<Output = Result<(), Error<ErrorT, Self::CachingError>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Serialize + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
A method to implement to set a value in the cache
It should return an error if the value could not be set
Auto Trait Implementations§
impl<'a> Freeze for RedisCache<'a>
impl<'a> RefUnwindSafe for RedisCache<'a>
impl<'a> Send for RedisCache<'a>
impl<'a> Sync for RedisCache<'a>
impl<'a> Unpin for RedisCache<'a>
impl<'a> UnwindSafe for RedisCache<'a>
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