Skip to main content

CacheStore

Trait CacheStore 

Source
pub trait CacheStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn get<'a>(
        &'a self,
        key: &'a CacheKey,
    ) -> Pin<Box<dyn Future<Output = Result<Option<CacheEntry>, CacheError>> + Send + 'a>>;
    fn set(
        &self,
        key: CacheKey,
        entry: CacheEntry,
    ) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + '_>>;
    fn delete<'a>(
        &'a self,
        key: &'a CacheKey,
    ) -> Pin<Box<dyn Future<Output = Result<bool, CacheError>> + Send + 'a>>;
    fn delete_tag<'a>(
        &'a self,
        tag: &'a str,
    ) -> Pin<Box<dyn Future<Output = Result<usize, CacheError>> + Send + 'a>>;
    fn clear(
        &self,
    ) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + '_>>;
}
Expand description

Storage backend.

Implementations must be safe to share between threads. Stale entries are returned by get (stale-while-revalidate is decided by the caller).

Required Methods§

Source

fn get<'a>( &'a self, key: &'a CacheKey, ) -> Pin<Box<dyn Future<Output = Result<Option<CacheEntry>, CacheError>> + Send + 'a>>

Source

fn set( &self, key: CacheKey, entry: CacheEntry, ) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + '_>>

Source

fn delete<'a>( &'a self, key: &'a CacheKey, ) -> Pin<Box<dyn Future<Output = Result<bool, CacheError>> + Send + 'a>>

Source

fn delete_tag<'a>( &'a self, tag: &'a str, ) -> Pin<Box<dyn Future<Output = Result<usize, CacheError>> + Send + 'a>>

Delete every entry carrying tag; returns the number removed.

Source

fn clear( &self, ) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + '_>>

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§