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 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<String>, FrameworkError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn put_raw<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        value: &'life2 str,
        ttl: Option<Duration>,
    ) -> Pin<Box<dyn Future<Output = Result<(), FrameworkError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn has<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool, FrameworkError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn forget<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool, FrameworkError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn flush<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), FrameworkError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn increment<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        amount: i64,
    ) -> Pin<Box<dyn Future<Output = Result<i64, FrameworkError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn decrement<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        amount: i64,
    ) -> Pin<Box<dyn Future<Output = Result<i64, FrameworkError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn expire<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        ttl: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<bool, FrameworkError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Cache store trait - all cache backends must implement this

This trait uses JSON strings for values to enable dynamic typing. The Cache facade handles serialization/deserialization.

Required Methods§

Source

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

Retrieve a raw JSON value from the cache by key

Source

fn put_raw<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 str, value: &'life2 str, ttl: Option<Duration>, ) -> Pin<Box<dyn Future<Output = Result<(), FrameworkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store a raw JSON value in the cache

Source

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

Check if a key exists in the cache

Source

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

Remove an item from the cache

Source

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

Remove all items from the cache

Source

fn increment<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, amount: i64, ) -> Pin<Box<dyn Future<Output = Result<i64, FrameworkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Increment a numeric value

Returns the new value after incrementing.

Source

fn decrement<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, amount: i64, ) -> Pin<Box<dyn Future<Output = Result<i64, FrameworkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Decrement a numeric value

Returns the new value after decrementing.

Source

fn expire<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<bool, FrameworkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Set a TTL on an existing key

Returns true if the key existed and TTL was set, false if key not found.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§