Expiry

Trait Expiry 

Source
pub trait Expiry: Send + Sync {
    // Required methods
    fn persist<'life0, 'async_trait>(
        &'life0 self,
        scope: Arc<[u8]>,
        key: Arc<[u8]>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn expire<'life0, 'async_trait>(
        &'life0 self,
        scope: Arc<[u8]>,
        key: Arc<[u8]>,
        expire_in: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn expiry<'life0, 'async_trait>(
        &'life0 self,
        scope: Arc<[u8]>,
        key: Arc<[u8]>,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Duration>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn extend<'life0, 'async_trait>(
        &'life0 self,
        scope: Arc<[u8]>,
        key: Arc<[u8]>,
        expire_in: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn set_called<'life0, 'async_trait>(
        &'life0 self,
        key: Arc<[u8]>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Set of method for expiry providers to implement.

The expiry itself should guarantee that it’s working on the correct storage and provide a hint that it’s persistant or temprorary.

Required Methods§

Source

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

Remove all expiry requests from a key and make it persistent, the persistenty can be overwriten by calling expire on the key.

Source

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

Sets an expiry for a key, the key may or may not be removed based on implementation, but it should be guaranteed that it won’t appear in get based methods or contains checks after the period specified.

Source

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

Gets expiry for a key, returning None means it doesn’t have an expiry, if the provider can’t return an expiry, it should return an error instead. The result of this function can have some error, but it should be documented.

Provided Methods§

Source

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

Extend expiry for a key for another duration of time. If the key doesn’t have an expiry, it should be equivalent of calling expire.

Source

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

A notification that should be implemented if expiry is a different entity that store itself to remove expiry when set is called for a key.

Implementations on Foreign Types§

Source§

impl<T> Expiry for Addr<T>

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§