CacheAdapterExt

Trait CacheAdapterExt 

Source
pub trait CacheAdapterExt: CacheAdapter {
    // Provided methods
    fn get_or_set<'a, F, Fut>(
        &'a self,
        key: CacheKey,
        ttl: Duration,
        compute: F,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'a>>
       where F: FnOnce() -> Fut + Send + 'a,
             Fut: Future<Output = Result<Vec<u8>>> + Send + 'a { ... }
    fn get_or_set_default<'a, F, Fut>(
        &'a self,
        key: CacheKey,
        compute: F,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'a>>
       where F: FnOnce() -> Fut + Send + 'a,
             Fut: Future<Output = Result<Vec<u8>>> + Send + 'a { ... }
}
Expand description

Extension trait providing convenience methods for caching

Provided Methods§

Source

fn get_or_set<'a, F, Fut>( &'a self, key: CacheKey, ttl: Duration, compute: F, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'a>>
where F: FnOnce() -> Fut + Send + 'a, Fut: Future<Output = Result<Vec<u8>>> + Send + 'a,

Get a cached value, or compute and cache it if not present

Source

fn get_or_set_default<'a, F, Fut>( &'a self, key: CacheKey, compute: F, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'a>>
where F: FnOnce() -> Fut + Send + 'a, Fut: Future<Output = Result<Vec<u8>>> + Send + 'a,

Get a cached value using the key’s default TTL for caching

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§