salvo_cache

Trait CacheStore

source
pub trait CacheStore:
    Send
    + Sync
    + 'static {
    type Error: StdError + Sync + Send + 'static;
    type Key: Hash + Eq + Send + Clone + 'static;

    // Required methods
    fn load_entry<Q>(
        &self,
        key: &Q,
    ) -> impl Future<Output = Option<CachedEntry>> + Send
       where Self::Key: Borrow<Q>,
             Q: Hash + Eq + Sync;
    fn save_entry(
        &self,
        key: Self::Key,
        data: CachedEntry,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
}
Expand description

Store cache.

Required Associated Types§

source

type Error: StdError + Sync + Send + 'static

Error type for CacheStore.

source

type Key: Hash + Eq + Send + Clone + 'static

Key

Required Methods§

source

fn load_entry<Q>( &self, key: &Q, ) -> impl Future<Output = Option<CachedEntry>> + Send
where Self::Key: Borrow<Q>, Q: Hash + Eq + Sync,

Get the cache item from the store.

source

fn save_entry( &self, key: Self::Key, data: CachedEntry, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Save the cache item from the store.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<K> CacheStore for MokaStore<K>
where K: Hash + Eq + Send + Sync + Clone + 'static,

Available on crate feature moka-store only.