CacheStore

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 to the store.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so 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.