Skip to main content

CacheAdapter

Trait CacheAdapter 

Source
pub trait CacheAdapter: Send + Sync {
    // Required methods
    fn set<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        value: &'life2 str,
        expires_in: TimeDelta,
    ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<String>, AuthError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn exists<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool, AuthError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn expire<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        expires_in: TimeDelta,
    ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn clear<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn set_without_expiry<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _key: &'life1 str,
        _value: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait { ... }
    fn get_and_delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<String>, AuthError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
    fn increment<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _key: &'life1 str,
        _expires_in: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<f64, AuthError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

Cache adapter trait for session caching

Required Methods§

Source

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

Set a value with expiration

Source

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

Get a value by key

Source

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

Delete a value by key

Source

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

Check if key exists

Source

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

Set expiration for a key

Source

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

Clear all cached values

Provided Methods§

Source

fn set_without_expiry<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _key: &'life1 str, _value: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Persist a value without expiration. Adapters must explicitly support this capability.

Source

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

Atomically fetch and remove a value. A read followed by a separate delete does not satisfy single-use token semantics.

Source

fn increment<'life0, 'life1, 'async_trait>( &'life0 self, _key: &'life1 str, _expires_in: Duration, ) -> Pin<Box<dyn Future<Output = Result<f64, AuthError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Atomically increment a counter, setting its TTL only on creation. Existing TTLs must not be extended by admitted or rejected requests.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§