ExpiryStore

Trait ExpiryStore 

Source
pub trait ExpiryStore:
    Store
    + Expiry
    + Send
    + Sync {
    // Provided methods
    fn set_expiring<'life0, 'async_trait>(
        &'life0 self,
        scope: Arc<[u8]>,
        key: Arc<[u8]>,
        value: Arc<[u8]>,
        expire_in: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn get_expiring<'life0, 'async_trait>(
        &'life0 self,
        scope: Arc<[u8]>,
        key: Arc<[u8]>,
    ) -> Pin<Box<dyn Future<Output = Result<Option<(Arc<[u8]>, Option<Duration>)>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

It is usefull for when store and expiry are implemented for the same struct, and should be implemented in those cases even if there can’t be any optimization, as it will prevent some runtime checks for expiry validity.

Provided Methods§

Source

fn set_expiring<'life0, 'async_trait>( &'life0 self, scope: Arc<[u8]>, key: Arc<[u8]>, value: Arc<[u8]>, expire_in: Duration, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set a key-value for a duration of time, if the key already exists, it should overwrite both the value and the expiry for that key.

Source

fn get_expiring<'life0, 'async_trait>( &'life0 self, scope: Arc<[u8]>, key: Arc<[u8]>, ) -> Pin<Box<dyn Future<Output = Result<Option<(Arc<[u8]>, Option<Duration>)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the value and expiry for a key, it is possible to return None if the key doesn’t exist, or return None for the expiry if the key is persistent.

Implementations on Foreign Types§

Source§

impl<T> ExpiryStore for Addr<T>

Source§

fn set_expiring<'life0, 'async_trait>( &'life0 self, scope: Arc<[u8]>, key: Arc<[u8]>, value: Arc<[u8]>, expire_in: Duration, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn get_expiring<'life0, 'async_trait>( &'life0 self, scope: Arc<[u8]>, key: Arc<[u8]>, ) -> Pin<Box<dyn Future<Output = Result<Option<(Arc<[u8]>, Option<Duration>)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§