Trait il2_utils::cache::CacheEngine [−][src]
pub trait CacheEngine<K: Eq + Hash + Copy + Sync, V: Send + Sync>: Sync {
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
Gets the value from the cache if it exists.
Arguments:
key: The key to be found;
Returns:
Some(v): The cached value.vis a newArcthat points to it.None: IF the entry is not in the cache;
Inserts the value into the cache.
Arguments:
key: The key;value: A reference to anArcthat points to the value;