Skip to main content

CacheStore

Trait CacheStore 

Source
pub trait CacheStore: Send + Sync {
    // Required methods
    fn get_raw<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 CacheKey,
    ) -> Pin<Box<dyn Future<Output = CacheResult<Option<Vec<u8>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn set_raw<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 CacheKey,
        value: Vec<u8>,
        ttl: Option<Duration>,
    ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 CacheKey,
    ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn delete_many<'life0, 'life1, 'async_trait>(
        &'life0 self,
        keys: &'life1 [CacheKey],
    ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn get_json<'life0, 'life1, 'async_trait, T>(
        &'life0 self,
        key: &'life1 CacheKey,
    ) -> Pin<Box<dyn Future<Output = CacheResult<Option<T>>> + Send + 'async_trait>>
       where T: DeserializeOwned + Send + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn set_json<'life0, 'life1, 'life2, 'async_trait, T>(
        &'life0 self,
        key: &'life1 CacheKey,
        value: &'life2 T,
        ttl: Option<Duration>,
    ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
       where T: Serialize + Sync + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

Async cache store abstraction.

Required Methods§

Source

fn get_raw<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 CacheKey, ) -> Pin<Box<dyn Future<Output = CacheResult<Option<Vec<u8>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reads a raw value by key.

Source

fn set_raw<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 CacheKey, value: Vec<u8>, ttl: Option<Duration>, ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Writes a raw value with optional TTL.

Source

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

Deletes a value by key.

Provided Methods§

Source

fn delete_many<'life0, 'life1, 'async_trait>( &'life0 self, keys: &'life1 [CacheKey], ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deletes multiple values by key.

Backends can override this to batch keys by connection or shard. The default implementation preserves existing single-key semantics.

Source

fn get_json<'life0, 'life1, 'async_trait, T>( &'life0 self, key: &'life1 CacheKey, ) -> Pin<Box<dyn Future<Output = CacheResult<Option<T>>> + Send + 'async_trait>>
where T: DeserializeOwned + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reads a JSON value by key.

Source

fn set_json<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, key: &'life1 CacheKey, value: &'life2 T, ttl: Option<Duration>, ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
where T: Serialize + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Writes a JSON value with optional TTL.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§