pub trait CacheAccessor<K, V>: Send + Sync {
type Extra: Clone;
// Required methods
fn get(&self, k: &K) -> Option<V>;
fn get_with_extra(&self, k: &K, e: &Self::Extra) -> Option<V>;
fn put(&self, key: &K, value: V) -> Option<V>;
fn put_with_extra(&self, key: &K, value: V, e: &Self::Extra) -> Option<V>;
fn remove(&mut self, k: &K) -> Option<V>;
fn contains_key(&self, k: &K) -> bool;
fn len(&self) -> usize;
fn clear(&self);
fn name(&self) -> String;
// Provided method
fn is_empty(&self) -> bool { ... }
}
Expand description
The cache accessor, users usually working on this interface while manipulating caches.
This interface does not get mut
references and thus has to handle its own
locking via internal mutability. It can be accessed via multiple concurrent queries
during planning and execution.
Required Associated Types§
Required Methods§
Sourcefn get_with_extra(&self, k: &K, e: &Self::Extra) -> Option<V>
fn get_with_extra(&self, k: &K, e: &Self::Extra) -> Option<V>
Get value from cache.
Sourcefn put(&self, key: &K, value: V) -> Option<V>
fn put(&self, key: &K, value: V) -> Option<V>
Put value into cache. Returns the old value associated with the key if there was one.
Sourcefn put_with_extra(&self, key: &K, value: V, e: &Self::Extra) -> Option<V>
fn put_with_extra(&self, key: &K, value: V, e: &Self::Extra) -> Option<V>
Put value into cache. Returns the old value associated with the key if there was one.
Sourcefn remove(&mut self, k: &K) -> Option<V>
fn remove(&mut self, k: &K) -> Option<V>
Remove an entry from the cache, returning value if they existed in the map.
Sourcefn contains_key(&self, k: &K) -> bool
fn contains_key(&self, k: &K) -> bool
Check if the cache contains a specific key.