pub struct TieredCache<L1, L2>where
L1: CacheBackend,
L2: CacheBackend,{ /* private fields */ }Expand description
A tiered cache with L1 (local) and L2 (distributed) layers.
Implementations§
Source§impl<L1, L2> TieredCache<L1, L2>where
L1: CacheBackend,
L2: CacheBackend,
impl<L1, L2> TieredCache<L1, L2>where
L1: CacheBackend,
L2: CacheBackend,
Sourcepub fn with_config(l1: L1, l2: L2, config: TieredCacheConfig) -> Self
pub fn with_config(l1: L1, l2: L2, config: TieredCacheConfig) -> Self
Create with custom config.
Sourcepub fn config(&self) -> &TieredCacheConfig
pub fn config(&self) -> &TieredCacheConfig
Get the config.
Trait Implementations§
Source§impl<L1, L2> CacheBackend for TieredCache<L1, L2>where
L1: CacheBackend,
L2: CacheBackend,
impl<L1, L2> CacheBackend for TieredCache<L1, L2>where
L1: CacheBackend,
L2: CacheBackend,
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 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 get_many<T>(
&self,
keys: &[CacheKey],
) -> impl Future<Output = CacheResult<Vec<Option<T>>>> + Sendwhere
T: DeserializeOwned + Send,
fn get_many<T>(
&self,
keys: &[CacheKey],
) -> impl Future<Output = CacheResult<Vec<Option<T>>>> + Sendwhere
T: DeserializeOwned + Send,
Get multiple values at once. Read more
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
Auto Trait Implementations§
impl<L1, L2> Freeze for TieredCache<L1, L2>
impl<L1, L2> RefUnwindSafe for TieredCache<L1, L2>where
L1: RefUnwindSafe,
L2: RefUnwindSafe,
impl<L1, L2> Send for TieredCache<L1, L2>
impl<L1, L2> Sync for TieredCache<L1, L2>
impl<L1, L2> Unpin for TieredCache<L1, L2>
impl<L1, L2> UnwindSafe for TieredCache<L1, L2>where
L1: UnwindSafe,
L2: UnwindSafe,
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