Skip to main content

Cache

Trait Cache 

Source
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§

Source

fn get(&self, key: &str) -> Result<Option<Vec<u8>>, CacheError>

Source

fn set( &self, key: &str, value: Vec<u8>, ttl: Option<Duration>, ) -> Result<(), CacheError>

Source

fn delete(&self, key: &str) -> Result<(), CacheError>

Source

fn clear(&self) -> Result<(), CacheError>

Source

fn exists(&self, key: &str) -> Result<bool, CacheError>

Source

fn expire(&self, key: &str, ttl: Duration) -> Result<(), CacheError>

Source

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".

Implementors§