Trait Cache

Source
pub trait Cache {
    type Error;

    // Required methods
    fn fetch<T: Cacheable>(
        &mut self,
        key: &String,
    ) -> Result<Option<T>, Self::Error>;
    fn save<T: Cacheable>(
        &mut self,
        key: &String,
        item: &T,
        ttl: Duration,
    ) -> Result<(), Self::Error>;
    fn delete(&mut self, key: &String) -> Result<(), Self::Error>;
    fn clear(&mut self) -> Result<(), Self::Error>;
}
Expand description

Trait to implement for actual cache implementations

Required Associated Types§

Required Methods§

Source

fn fetch<T: Cacheable>( &mut self, key: &String, ) -> Result<Option<T>, Self::Error>

Source

fn save<T: Cacheable>( &mut self, key: &String, item: &T, ttl: Duration, ) -> Result<(), Self::Error>

Source

fn delete(&mut self, key: &String) -> Result<(), Self::Error>

Source

fn clear(&mut self) -> Result<(), Self::Error>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§