aurelin_framework/cache/
store.rs1use std::time::Duration;
2
3use async_trait::async_trait;
4
5use super::Error;
6
7#[async_trait]
9pub trait Store: Send + Sync + 'static {
10 async fn get(&self, key: &str) -> Result<Option<Vec<u8>>, Error>;
12
13 async fn put(&self, key: &str, value: Vec<u8>, ttl: Option<Duration>) -> Result<(), Error>;
15
16 async fn add(&self, key: &str, value: Vec<u8>, ttl: Option<Duration>) -> Result<bool, Error>;
18
19 async fn pull(&self, key: &str) -> Result<Option<Vec<u8>>, Error>;
21
22 async fn increment(&self, key: &str, amount: i64) -> Result<i64, Error>;
24
25 async fn touch(&self, key: &str, ttl: Duration) -> Result<bool, Error>;
27
28 async fn forget(&self, key: &str) -> Result<bool, Error>;
30
31 async fn flush(&self) -> Result<(), Error>;
33
34 async fn acquire_lock(&self, key: &str, owner: &str, ttl: Option<Duration>) -> Result<bool, Error>;
36
37 async fn release_lock(&self, key: &str, owner: &str) -> Result<bool, Error>;
39
40 async fn force_release_lock(&self, key: &str) -> Result<(), Error>;
42
43 async fn refresh_lock(&self, key: &str, owner: &str, ttl: Option<Duration>) -> Result<bool, Error>;
45
46 async fn lock_owner(&self, key: &str) -> Result<Option<String>, Error>;
48}