pub trait CacheServiceExt<K, V>: Sized {
// Required methods
fn get(
&self,
key: &K,
) -> impl Future<Output = Result<Option<CacheEntry<V>>, Error>> + Send;
fn insert(
&self,
key: K,
entry: CacheEntry<V>,
) -> impl Future<Output = Result<(), Error>> + Send;
fn invalidate(
&self,
key: &K,
) -> impl Future<Output = Result<(), Error>> + Send;
fn clear(&self) -> impl Future<Output = Result<(), Error>> + Send;
}Available on crate feature
service only.Expand description
Extension trait providing ergonomic cache methods for any Service<CacheOperation>.
This allows middleware-wrapped cache services to be used with the same
simple API as a direct Cache.
Required Methods§
Sourcefn get(
&self,
key: &K,
) -> impl Future<Output = Result<Option<CacheEntry<V>>, Error>> + Send
fn get( &self, key: &K, ) -> impl Future<Output = Result<Option<CacheEntry<V>>, Error>> + Send
Retrieves a value from the cache.
Sourcefn insert(
&self,
key: K,
entry: CacheEntry<V>,
) -> impl Future<Output = Result<(), Error>> + Send
fn insert( &self, key: K, entry: CacheEntry<V>, ) -> impl Future<Output = Result<(), Error>> + Send
Inserts a value into the cache.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".