Trait cached::IOCachedAsync

source ·
pub trait IOCachedAsync<K, V> {
    type Error;

    // Required methods
    fn cache_get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        k: &'life1 K
    ) -> Pin<Box<dyn Future<Output = Result<Option<V>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn cache_set<'life0, 'async_trait>(
        &'life0 self,
        k: K,
        v: V
    ) -> Pin<Box<dyn Future<Output = Result<Option<V>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn cache_remove<'life0, 'life1, 'async_trait>(
        &'life0 self,
        k: &'life1 K
    ) -> Pin<Box<dyn Future<Output = Result<Option<V>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn cache_set_refresh(&mut self, refresh: bool) -> bool;

    // Provided methods
    fn cache_lifespan(&self) -> Option<u64> { ... }
    fn cache_set_lifespan(&mut self, _seconds: u64) -> Option<u64> { ... }
}
Available on crate feature async only.

Required Associated Types§

Required Methods§

source

fn cache_get<'life0, 'life1, 'async_trait>( &'life0 self, k: &'life1 K ) -> Pin<Box<dyn Future<Output = Result<Option<V>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source

fn cache_set<'life0, 'async_trait>( &'life0 self, k: K, v: V ) -> Pin<Box<dyn Future<Output = Result<Option<V>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source

fn cache_remove<'life0, 'life1, 'async_trait>( &'life0 self, k: &'life1 K ) -> Pin<Box<dyn Future<Output = Result<Option<V>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a cached value

source

fn cache_set_refresh(&mut self, refresh: bool) -> bool

Set the flag to control whether cache hits refresh the ttl of cached values, returns the old flag value

Provided Methods§

source

fn cache_lifespan(&self) -> Option<u64>

Return the lifespan of cached values (time to eviction)

source

fn cache_set_lifespan(&mut self, _seconds: u64) -> Option<u64>

Set the lifespan of cached values, returns the old value

Implementors§