pub trait Cache {
// Required methods
fn save(&self, key: &str, value: Vec<u8>) -> Result<(), CacheError>;
fn get(&self, key: &str) -> Option<Vec<u8>>;
fn delete(&self, key: &str) -> Option<Vec<u8>>;
fn purge(&self);
}Expand description
Represents a cache. It stores each element as a new entry.
Required Methods§
Sourcefn save(&self, key: &str, value: Vec<u8>) -> Result<(), CacheError>
fn save(&self, key: &str, value: Vec<u8>) -> Result<(), CacheError>
Stores value in cache with provided key. Value should be already serialized.
If it already exists, stored value will be overridden with the new param value. Have in consideration that this might affect the Cache order, depending on the eviction strategy (FIFO or LRU caches).
If it is not possible to store the value in cache, it results in a CacheError.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".