pub struct MultiTierBackend<L1, L2> { /* private fields */ }Expand description
Multi-tier cache backend combining fast L1 and persistent L2.
The multi-tier backend automatically promotes frequently accessed entries from L2 to L1 based on the configured promotion strategy.
Implementations§
Source§impl<L1, L2> MultiTierBackend<L1, L2>where
L1: CacheBackend,
L2: CacheBackend,
impl<L1, L2> MultiTierBackend<L1, L2>where
L1: CacheBackend,
L2: CacheBackend,
Sourcepub fn new(l1: L1, l2: L2) -> Self
pub fn new(l1: L1, l2: L2) -> Self
Creates a new multi-tier backend with default configuration.
Sourcepub fn builder() -> MultiTierBuilder<L1, L2>
pub fn builder() -> MultiTierBuilder<L1, L2>
Creates a builder for configuring the multi-tier backend.
Trait Implementations§
Source§impl<L1, L2> CacheBackend for MultiTierBackend<L1, L2>where
L1: CacheBackend,
L2: CacheBackend,
impl<L1, L2> CacheBackend for MultiTierBackend<L1, L2>where
L1: CacheBackend,
L2: CacheBackend,
Source§async fn get_keys_by_tag(&self, tag: &str) -> Result<Vec<String>, CacheError>
async fn get_keys_by_tag(&self, tag: &str) -> Result<Vec<String>, CacheError>
Merges both tiers.
A tier that reports CacheError::Unsupported — the shared backends
keep no tag index — contributes nothing rather than failing the whole
call, so the common InMemoryBackend over RedisBackend arrangement
keeps working off the L1 index. Only if neither tier has an index is
the Unsupported error propagated.
Source§async fn invalidate_by_tag(&self, tag: &str) -> Result<usize, CacheError>
async fn invalidate_by_tag(&self, tag: &str) -> Result<usize, CacheError>
Invalidates in both tiers, tolerating a tier without a tag index in the
same way as get_keys_by_tag.
Merges both tiers, tolerating a tier without a tag index in the same
way as get_keys_by_tag.
Source§async fn get(&self, key: &str) -> Result<Option<CacheRead>, CacheError>
async fn get(&self, key: &str) -> Result<Option<CacheRead>, CacheError>
Source§async fn set(
&self,
key: String,
entry: CacheEntry,
ttl: Duration,
stale_for: Duration,
) -> Result<(), CacheError>
async fn set( &self, key: String, entry: CacheEntry, ttl: Duration, stale_for: Duration, ) -> Result<(), CacheError>
Source§async fn invalidate(&self, key: &str) -> Result<(), CacheError>
async fn invalidate(&self, key: &str) -> Result<(), CacheError>
key, if present.