Skip to main content

CacheDriver

Trait CacheDriver 

Source
pub trait CacheDriver: Sync + Send {
    // Required methods
    fn ping<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn contains_key<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = CacheResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = CacheResult<Option<String>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn insert<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        value: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn insert_with_expiry<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        value: &'life2 str,
        duration: Duration,
    ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn remove<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn clear<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait representing a cache driver.

Required Methods§

Source

fn ping<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Pings the cache to check if it is reachable.

§Errors

Returns a super::CacheError if there is an error during the operation.

Source

fn contains_key<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = CacheResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Checks if a key exists in the cache.

§Errors

Returns a super::CacheError if there is an error during the operation.

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = CacheResult<Option<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves a value from the cache based on the provided key.

§Errors

Returns a super::CacheError if there is an error during the operation.

Source

fn insert<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 str, value: &'life2 str, ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Inserts a key-value pair into the cache.

§Errors

Returns a super::CacheError if there is an error during the operation.

Source

fn insert_with_expiry<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 str, value: &'life2 str, duration: Duration, ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Inserts a key-value pair into the cache that expires after the specified duration.

§Errors

Returns a super::CacheError if there is an error during the operation.

Source

fn remove<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Removes a key-value pair from the cache.

§Errors

Returns a super::CacheError if there is an error during the operation.

Source

fn clear<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clears all key-value pairs from the cache.

§Errors

Returns a super::CacheError if there is an error during the operation.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§