pub trait CacheEngine<K: Eq + Hash + Copy + Sync, V: Send + Sync>: Sync {
// Required methods
fn get(&mut self, key: &K) -> Option<Arc<V>>;
fn insert(&mut self, key: K, value: &Arc<V>);
fn clear(&mut self);
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
}
Expand description
This trait is implemented by all value caches on this module. A value cache must be able to associate shared read-only values to a given key value.
It is up to the implementator of this trait to define how old values are prunned from the cache.
All methods of this trait are required to be thread safe.
Required Methods§
Sourcefn get(&mut self, key: &K) -> Option<Arc<V>>
fn get(&mut self, key: &K) -> Option<Arc<V>>
Gets the value from the cache if it exists.
Arguments:
key
: The key to be found;
Returns:
Some(v)
: The cached value.v
is a newArc
that points to it.None
: IF the entry is not in the cache;