CacheExt

Trait CacheExt 

Source
pub trait CacheExt: Cache {
    // Provided methods
    fn get_keyed<K, T>(
        &self,
        key: &K,
    ) -> Pin<Box<dyn Future<Output = Option<T>> + Send + '_>>
       where K: CacheKey,
             T: DeserializeOwned + Send { ... }
    fn set_keyed<'a, K, T>(
        &'a self,
        key: &K,
        value: T,
        ttl: Option<Duration>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>
       where K: CacheKey,
             T: Serialize + Send + Sync + 'a { ... }
    fn delete_keyed<K>(
        &self,
        key: &K,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + '_>>
       where K: CacheKey { ... }
}
Expand description

Extension trait for cache operations with typed keys

Provided Methods§

Source

fn get_keyed<K, T>( &self, key: &K, ) -> Pin<Box<dyn Future<Output = Option<T>> + Send + '_>>

Get a value using a typed cache key

Source

fn set_keyed<'a, K, T>( &'a self, key: &K, value: T, ttl: Option<Duration>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>
where K: CacheKey, T: Serialize + Send + Sync + 'a,

Set a value using a typed cache key

Source

fn delete_keyed<K>( &self, key: &K, ) -> Pin<Box<dyn Future<Output = bool> + Send + '_>>
where K: CacheKey,

Delete a value using a typed cache key

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<C> CacheExt for C
where C: Cache + ?Sized,