pub trait CacheStorage:
Send
+ Sync
+ Debug {
// Required methods
fn store(
&mut self,
key: CacheKey,
value: CacheValue,
ttl: Option<Duration>,
) -> Result<()>;
fn retrieve(&self, key: &CacheKey) -> Option<CacheValue>;
fn remove(&mut self, key: &CacheKey) -> bool;
fn size_info(&self) -> CacheSizeInfo;
fn clear(&mut self);
fn statistics(&self) -> StorageStatistics;
}Expand description
Cache storage trait for different storage implementations
Required Methods§
Sourcefn store(
&mut self,
key: CacheKey,
value: CacheValue,
ttl: Option<Duration>,
) -> Result<()>
fn store( &mut self, key: CacheKey, value: CacheValue, ttl: Option<Duration>, ) -> Result<()>
Store an item in the cache
Sourcefn retrieve(&self, key: &CacheKey) -> Option<CacheValue>
fn retrieve(&self, key: &CacheKey) -> Option<CacheValue>
Retrieve an item from the cache
Sourcefn size_info(&self) -> CacheSizeInfo
fn size_info(&self) -> CacheSizeInfo
Get cache size information
Sourcefn statistics(&self) -> StorageStatistics
fn statistics(&self) -> StorageStatistics
Get storage-specific statistics