Skip to main content

StorageAccess

Trait StorageAccess 

Source
pub trait StorageAccess<K, V>: Send + Sync
where K: Hash + Eq + Clone + Send + Sync + 'static, V: Clone + Send + Sync + 'static,
{ // Required methods fn get(&self, key: &K) -> Option<V>; fn put(&self, key: K, value: V); fn invalidate(&self, key: &K); fn clear(&self); // Provided method fn contains(&self, key: &K) -> bool { ... } }
Expand description

Synchronous key-value cache interface.

K is the key type; V is the value type.

Required Methods§

Source

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

Returns the value for key, or None when absent.

Source

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

Stores value under key, overwriting any existing entry.

Source

fn invalidate(&self, key: &K)

Removes the entry for key, if present.

Source

fn clear(&self)

Removes all entries.

Provided Methods§

Source

fn contains(&self, key: &K) -> bool

Returns true when a value is present for key.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<K, V> StorageAccess<K, V> for InMemoryStorageAccess<K, V>
where K: Hash + Eq + Clone + Send + Sync + 'static, V: Clone + Send + Sync + 'static,

Source§

impl<K, V> StorageAccess<K, V> for RedisStorageAccess
where K: Hash + Eq + Clone + ToString + Send + Sync + 'static, V: Clone + Serialize + DeserializeOwned + Send + Sync + 'static,