pub struct CacheLayer { /* private fields */ }Expand description
Main cache layer implementation
Implementations§
Source§impl CacheLayer
impl CacheLayer
Sourcepub async fn new(config: CacheConfig) -> Result<Self, CacheError>
pub async fn new(config: CacheConfig) -> Result<Self, CacheError>
Create a new cache layer
Sourcepub async fn set(
&self,
key: &str,
value: Value,
ttl_seconds: Option<u64>,
) -> Result<(), CacheError>
pub async fn set( &self, key: &str, value: Value, ttl_seconds: Option<u64>, ) -> Result<(), CacheError>
Set a value in cache
Sourcepub async fn ttl(&self, key: &str) -> Result<Option<i64>, CacheError>
pub async fn ttl(&self, key: &str) -> Result<Option<i64>, CacheError>
Get time to live for a key
Sourcepub async fn increment(&self, key: &str, amount: i64) -> Result<i64, CacheError>
pub async fn increment(&self, key: &str, amount: i64) -> Result<i64, CacheError>
Increment a numeric value
Sourcepub async fn clear(&self) -> Result<(), CacheError>
pub async fn clear(&self) -> Result<(), CacheError>
Clear all cache entries
Sourcepub async fn get_statistics(&self) -> CacheStats
pub async fn get_statistics(&self) -> CacheStats
Get cache statistics
Auto Trait Implementations§
impl Freeze for CacheLayer
impl !RefUnwindSafe for CacheLayer
impl Send for CacheLayer
impl Sync for CacheLayer
impl Unpin for CacheLayer
impl !UnwindSafe for CacheLayer
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