Skip to main content

CacheBackend

Trait CacheBackend 

Source
pub trait CacheBackend<K, V>: Send + Sync
where K: Send + Sync + 'static, V: Send + Sync + 'static,
{ // Required methods fn get<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 K, ) -> Pin<Box<dyn Future<Output = Option<V>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn set<'life0, 'async_trait>( &'life0 self, key: K, value: V, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; }
Expand description

Pluggable cache backend.

Implementations decide eviction, TTL, and persistence. The default MemoryCache is unbounded and lives only as long as the process.

Required Methods§

Source

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

Look up a value. None if not present.

Source

fn set<'life0, 'async_trait>( &'life0 self, key: K, value: V, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Store a value.

Implementors§

Source§

impl<K, V> CacheBackend<K, V> for MemoryCache<K, V>
where K: Hash + Eq + Send + Sync + Clone + 'static, V: Clone + Send + Sync + 'static,