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> { ... }
}
Required 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 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,
sourcefn 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_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
sourcefn 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§
sourcefn cache_lifespan(&self) -> Option<u64>
fn cache_lifespan(&self) -> Option<u64>
Return the lifespan of cached values (time to eviction)
sourcefn 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