pub struct RedisCache { /* private fields */ }Expand description
Redis cache backend.
Implementations§
Source§impl RedisCache
impl RedisCache
Sourcepub async fn new(config: RedisCacheConfig) -> CacheResult<Self>
pub async fn new(config: RedisCacheConfig) -> CacheResult<Self>
Create a new Redis cache.
Sourcepub async fn from_url(url: &str) -> CacheResult<Self>
pub async fn from_url(url: &str) -> CacheResult<Self>
Create from a URL.
Sourcepub fn connection(&self) -> &RedisConnection
pub fn connection(&self) -> &RedisConnection
Get the connection.
Sourcepub fn config(&self) -> &RedisCacheConfig
pub fn config(&self) -> &RedisCacheConfig
Get the config.
Trait Implementations§
Source§impl CacheBackend for RedisCache
impl CacheBackend for RedisCache
Source§async fn get<T>(&self, key: &CacheKey) -> CacheResult<Option<T>>where
T: DeserializeOwned,
async fn get<T>(&self, key: &CacheKey) -> CacheResult<Option<T>>where
T: DeserializeOwned,
Get a value from the cache.
Source§async fn set<T>(
&self,
key: &CacheKey,
value: &T,
ttl: Option<Duration>,
) -> CacheResult<()>
async fn set<T>( &self, key: &CacheKey, value: &T, ttl: Option<Duration>, ) -> CacheResult<()>
Set a value in the cache.
Source§async fn get_many<T>(&self, keys: &[CacheKey]) -> CacheResult<Vec<Option<T>>>where
T: DeserializeOwned,
async fn get_many<T>(&self, keys: &[CacheKey]) -> CacheResult<Vec<Option<T>>>where
T: DeserializeOwned,
Get multiple values at once. Read more
Source§async fn invalidate_pattern(&self, pattern: &KeyPattern) -> CacheResult<u64>
async fn invalidate_pattern(&self, pattern: &KeyPattern) -> CacheResult<u64>
Invalidate entries matching a pattern.
Invalidate entries by tags.
Source§async fn clear(&self) -> CacheResult<()>
async fn clear(&self) -> CacheResult<()>
Clear all entries.
Source§async fn len(&self) -> CacheResult<usize>
async fn len(&self) -> CacheResult<usize>
Get the approximate number of entries.
Source§async fn stats(&self) -> CacheResult<BackendStats>
async fn stats(&self) -> CacheResult<BackendStats>
Get cache statistics if available.
Source§fn set_many<T>(
&self,
entries: &[(&CacheKey, &T)],
ttl: Option<Duration>,
) -> impl Future<Output = CacheResult<()>> + Send
fn set_many<T>( &self, entries: &[(&CacheKey, &T)], ttl: Option<Duration>, ) -> impl Future<Output = CacheResult<()>> + Send
Set multiple values at once. Read more
Source§fn delete_many(
&self,
keys: &[CacheKey],
) -> impl Future<Output = CacheResult<u64>> + Send
fn delete_many( &self, keys: &[CacheKey], ) -> impl Future<Output = CacheResult<u64>> + Send
Delete multiple keys at once. Read more
Source§impl Clone for RedisCache
impl Clone for RedisCache
Source§fn clone(&self) -> RedisCache
fn clone(&self) -> RedisCache
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RedisCache
impl RefUnwindSafe for RedisCache
impl Send for RedisCache
impl Sync for RedisCache
impl Unpin for RedisCache
impl UnwindSafe 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