Trait cached::IOCachedAsync
source · [−]pub trait IOCachedAsync<K, V> {
type Error;
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
'life0: 'async_trait,
'life1: 'async_trait,
Self: '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
'life0: 'async_trait,
Self: '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
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn cache_set_refresh(&mut self, refresh: bool) -> bool;
fn cache_lifespan(&self) -> Option<u64> { ... }
fn cache_set_lifespan(&mut self, _seconds: u64) -> Option<u64> { ... }
}
Associated Types
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
'life0: 'async_trait,
'life1: 'async_trait,
Self: '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
'life0: 'async_trait,
Self: 'async_trait,
Remove a cached value
fn cache_set_refresh(&mut self, refresh: bool) -> bool
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
fn cache_lifespan(&self) -> Option<u64>
fn cache_lifespan(&self) -> Option<u64>
Return the lifespan of cached values (time to eviction)
fn cache_set_lifespan(&mut self, _seconds: u64) -> Option<u64>
fn cache_set_lifespan(&mut self, _seconds: u64) -> Option<u64>
Set the lifespan of cached values, returns the old value