Trait Cache

Source
pub trait Cache: Send {
    type Input: Hash + Eq + Sync + 'static;
    type Output: Clone + Sync + 'static;

    // Required methods
    fn new(config: CacheConfig) -> Self;
    fn get(
        &self,
        key: &Self::Input,
    ) -> impl Future<Output = Option<Self::Output>> + Send;
    fn set(
        &self,
        key: Self::Input,
        value: Self::Output,
    ) -> impl Future<Output = ()> + Send;
}

Required Associated Types§

Source

type Input: Hash + Eq + Sync + 'static

Source

type Output: Clone + Sync + 'static

Required Methods§

Source

fn new(config: CacheConfig) -> Self

Source

fn get( &self, key: &Self::Input, ) -> impl Future<Output = Option<Self::Output>> + Send

Source

fn set( &self, key: Self::Input, value: Self::Output, ) -> impl Future<Output = ()> + Send

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<I, O> Cache for MokaCache<I, O>
where I: Hash + Eq + Send + Sync + 'static, O: Clone + Send + Sync + 'static,

Source§

type Input = I

Source§

type Output = O