pub struct TieredCache<L1, L2>where
L1: CacheStore,
L2: CacheStore,{ /* private fields */ }Expand description
Multi-tier cache with L1 (in-memory) and L2 (distributed) layers
Implementations§
Source§impl<L1, L2> TieredCache<L1, L2>where
L1: CacheStore,
L2: CacheStore,
impl<L1, L2> TieredCache<L1, L2>where
L1: CacheStore,
L2: CacheStore,
Sourcepub fn with_config(l1: Arc<L1>, l2: Arc<L2>, config: TieredCacheConfig) -> Self
pub fn with_config(l1: Arc<L1>, l2: Arc<L2>, config: TieredCacheConfig) -> Self
Create with custom configuration
Sourcepub async fn get(&self, key: &str) -> CacheResult<Option<String>>
pub async fn get(&self, key: &str) -> CacheResult<Option<String>>
Get value from cache (checks L1 then L2)
Sourcepub async fn set(
&self,
key: &str,
value: String,
ttl: Option<Duration>,
) -> CacheResult<()>
pub async fn set( &self, key: &str, value: String, ttl: Option<Duration>, ) -> CacheResult<()>
Set value in cache (writes to both L1 and L2)
Sourcepub async fn delete(&self, key: &str) -> CacheResult<()>
pub async fn delete(&self, key: &str) -> CacheResult<()>
Delete from both L1 and L2
Sourcepub async fn exists(&self, key: &str) -> CacheResult<bool>
pub async fn exists(&self, key: &str) -> CacheResult<bool>
Check if key exists (checks L1 then L2)
Sourcepub async fn clear(&self) -> CacheResult<()>
pub async fn clear(&self) -> CacheResult<()>
Clear both L1 and L2
Sourcepub async fn stats(&self) -> CacheStats
pub async fn stats(&self) -> CacheStats
Get cache statistics
Trait Implementations§
Source§impl<L1, L2> Clone for TieredCache<L1, L2>where
L1: CacheStore,
L2: CacheStore,
impl<L1, L2> Clone for TieredCache<L1, L2>where
L1: CacheStore,
L2: CacheStore,
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: RefUnwindSafe,
L2: RefUnwindSafe,
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