1use std::time::Duration;
13
14pub use ::redis;
16
17pub trait Cache: Send + Sync {
18 fn set_nx_px(
19 &self,
20 key: &[u8],
21 value: &[u8],
22 ttl: Duration,
23 ) -> impl Future<Output = anyhow::Result<bool>> + Send;
24
25 fn set(
26 &self,
27 key: &[u8],
28 value: &[u8],
29 ttl: Duration,
30 ) -> impl Future<Output = anyhow::Result<()>> + Send;
31
32 fn get(&self, key: &[u8]) -> impl Future<Output = anyhow::Result<Option<Vec<u8>>>> + Send;
33
34 fn del(&self, key: &[u8]) -> impl Future<Output = anyhow::Result<()>> + Send;
35}
36
37mod local;
38mod redis_cache;
39mod utils;
40
41pub use local::LocalCache;
42pub use redis_cache::RedisCache;
43pub use utils::namespaced;
44pub mod set;
45pub use set::RedisSet;
46
47pub mod mock;
49
50#[cfg(test)]
51mod tests;