use std::sync::Arc;
use std::time::Duration;
use crate::Result;
#[async_trait::async_trait]
pub trait Expiry: Send + Sync {
async fn persist(&self, scope: Arc<[u8]>, key: Arc<[u8]>) -> Result<()>;
async fn expire(&self, scope: Arc<[u8]>, key: Arc<[u8]>, expire_in: Duration) -> Result<()>;
async fn expiry(&self, scope: Arc<[u8]>, key: Arc<[u8]>) -> Result<Option<Duration>>;
async fn extend(&self, scope: Arc<[u8]>, key: Arc<[u8]>, expire_in: Duration) -> Result<()> {
let expiry = self.expiry(scope.clone(), key.clone()).await?;
self.expire(scope, key, expiry.unwrap_or_default() + expire_in)
.await
}
#[allow(unused_variables)]
async fn set_called(&self, key: Arc<[u8]>) {}
}