Trait cfxcore::db::Cache

source ·
pub trait Cache<K, V> {
    // Required methods
    fn insert(&mut self, k: K, v: V) -> Option<V>;
    fn invalidate(&mut self, k: &K) -> Option<V>;
    fn get(&self, k: &K) -> Option<&V>;
}
Expand description

A cache for arbitrary key-value pairs.

Required Methods§

source

fn insert(&mut self, k: K, v: V) -> Option<V>

Insert an entry into the cache and get the old value.

source

fn invalidate(&mut self, k: &K) -> Option<V>

Invalidate an entry in the cache, getting the old value if it existed.

source

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

Query the cache for a key’s associated value.

Implementations on Foreign Types§

source§

impl<K, V> Cache<K, V> for HashMap<K, V>
where K: Hash + Eq,

source§

fn insert(&mut self, k: K, v: V) -> Option<V>

source§

fn invalidate(&mut self, k: &K) -> Option<V>

source§

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

Implementors§