CacheStorage

Trait CacheStorage 

Source
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§

Source

fn store( &mut self, key: CacheKey, value: CacheValue, ttl: Option<Duration>, ) -> Result<()>

Store an item in the cache

Source

fn retrieve(&self, key: &CacheKey) -> Option<CacheValue>

Retrieve an item from the cache

Source

fn remove(&mut self, key: &CacheKey) -> bool

Remove an item from the cache

Source

fn size_info(&self) -> CacheSizeInfo

Get cache size information

Source

fn clear(&mut self)

Clear the entire cache

Source

fn statistics(&self) -> StorageStatistics

Get storage-specific statistics

Implementors§