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 (i.e. LIFO, FIFO or LRU caches). Currently, only FIFO cache is offered.
If it is not possible to store the value in cache, it results in a CacheError.