pub trait Cache<T: Clone>: Send + Sync {
// Required methods
fn get_with<'life0, 'async_trait>(
&'life0 self,
key: String,
future: Box<dyn Future<Output = T> + Send>,
) -> Pin<Box<dyn Future<Output = Result<T, CacheError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
A cache.
Required Methods§
Sourcefn get_with<'life0, 'async_trait>(
&'life0 self,
key: String,
future: Box<dyn Future<Output = T> + Send>,
) -> Pin<Box<dyn Future<Output = Result<T, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_with<'life0, 'async_trait>(
&'life0 self,
key: String,
future: Box<dyn Future<Output = T> + Send>,
) -> Pin<Box<dyn Future<Output = Result<T, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Gets a cached value.
If a cached value is not found, it awaits the given future and sets its resulting value into the cache and returns the value.