pub trait Cache: Send + Sync {
// Required methods
fn get(&self, key: &str) -> Result<Option<Vec<u8>>, CacheError>;
fn set(
&self,
key: &str,
value: Vec<u8>,
ttl: Option<Duration>,
) -> Result<(), CacheError>;
fn delete(&self, key: &str) -> Result<(), CacheError>;
fn clear(&self) -> Result<(), CacheError>;
fn exists(&self, key: &str) -> Result<bool, CacheError>;
fn expire(&self, key: &str, ttl: Duration) -> Result<(), CacheError>;
fn ttl(&self, key: &str) -> Result<Option<Duration>, CacheError>;
}Required Methods§
fn get(&self, key: &str) -> Result<Option<Vec<u8>>, CacheError>
fn set( &self, key: &str, value: Vec<u8>, ttl: Option<Duration>, ) -> Result<(), CacheError>
fn delete(&self, key: &str) -> Result<(), CacheError>
fn clear(&self) -> Result<(), CacheError>
fn exists(&self, key: &str) -> Result<bool, CacheError>
fn expire(&self, key: &str, ttl: Duration) -> Result<(), CacheError>
fn ttl(&self, key: &str) -> Result<Option<Duration>, CacheError>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".