pub struct MultiTierCache { /* private fields */ }Expand description
Multi-tier cache with L1 (in-memory) and L2 (Redis) layers
Implementations§
Source§impl MultiTierCache
impl MultiTierCache
Sourcepub fn new(l2_cache: Arc<RedisCache>, config: MultiTierCacheConfig) -> Self
pub fn new(l2_cache: Arc<RedisCache>, config: MultiTierCacheConfig) -> Self
Create a new multi-tier cache
Sourcepub async fn get<T: DeserializeOwned + Serialize>(
&self,
key: &str,
) -> Result<Option<T>>
pub async fn get<T: DeserializeOwned + Serialize>( &self, key: &str, ) -> Result<Option<T>>
Get a value from the cache
Sourcepub async fn set<T: Serialize>(&self, key: &str, value: &T) -> Result<()>
pub async fn set<T: Serialize>(&self, key: &str, value: &T) -> Result<()>
Set a value in the cache
Sourcepub fn cleanup_l1(&self)
pub fn cleanup_l1(&self)
Cleanup expired and inactive L1 entries
Sourcepub fn stats(&self) -> MultiTierStats
pub fn stats(&self) -> MultiTierStats
Get cache statistics
Auto Trait Implementations§
impl Freeze for MultiTierCache
impl !RefUnwindSafe for MultiTierCache
impl Send for MultiTierCache
impl Sync for MultiTierCache
impl Unpin for MultiTierCache
impl !UnwindSafe for MultiTierCache
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more