Cache

Trait Cache 

Source
pub trait Cache<K, V>: Send + Sync {
    // Required methods
    fn get(&self, key: &K) -> Option<V>;
    fn put(&self, key: K, value: V, ttl_secs: u64);
    fn remove(&self, key: &K) -> Option<V>;
    fn clear(&self);
}
Expand description

Cache trait for storing and retrieving values with TTL

Required Methods§

Source

fn get(&self, key: &K) -> Option<V>

Get a value from the cache

Source

fn put(&self, key: K, value: V, ttl_secs: u64)

Put a value into the cache with TTL in seconds

Source

fn remove(&self, key: &K) -> Option<V>

Remove a value from the cache

Source

fn clear(&self)

Clear all values from the cache

Implementors§

Source§

impl<K, V> Cache<K, V> for MemoryCache

Source§

impl<K, V> Cache<K, V> for NoOpCache

Source§

impl<K: Hash + Eq + Clone + Send + Sync + 'static, V: Clone + Send + Sync + 'static> Cache<K, V> for MokaCacheImpl<K, V>

Available on non-WebAssembly and crate feature moka only.
Source§

impl<K: Hash + Eq + Clone + Send + Sync + Display, V: Clone + Send + Sync> Cache<K, V> for LruCacheImpl<K, V>

Available on crate feature lru only.