Skip to main content

CacheStore

Trait CacheStore 

Source
pub trait CacheStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn get<'a>(
        &'a self,
        key: &'a CacheKey,
    ) -> BoxFuture<'a, Result<Option<CacheEntry>, CacheError>>;
    fn set(
        &self,
        key: CacheKey,
        entry: CacheEntry,
    ) -> BoxFuture<'_, Result<(), CacheError>>;
    fn delete<'a>(
        &'a self,
        key: &'a CacheKey,
    ) -> BoxFuture<'a, Result<bool, CacheError>>;
    fn delete_tag<'a>(
        &'a self,
        tag: &'a str,
    ) -> BoxFuture<'a, Result<usize, CacheError>>;
    fn clear(&self) -> BoxFuture<'_, Result<(), CacheError>>;
}
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, ) -> BoxFuture<'a, Result<Option<CacheEntry>, CacheError>>

Source

fn set( &self, key: CacheKey, entry: CacheEntry, ) -> BoxFuture<'_, Result<(), CacheError>>

Source

fn delete<'a>( &'a self, key: &'a CacheKey, ) -> BoxFuture<'a, Result<bool, CacheError>>

Source

fn delete_tag<'a>( &'a self, tag: &'a str, ) -> BoxFuture<'a, Result<usize, CacheError>>

Delete every entry carrying tag; returns the number removed.

Source

fn clear(&self) -> BoxFuture<'_, Result<(), CacheError>>

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§