1use crate::error::Result;
2use async_trait::async_trait;
3use std::time::Duration;
4
5#[async_trait]
7pub trait CacheManager: Send + Sync {
8 async fn has(&self, key: &str) -> Result<bool>;
10
11 async fn get(&self, key: &str) -> Result<Option<String>>;
14
15 async fn set(&self, key: &str, value: &str, ttl_seconds: u64) -> Result<()>;
17
18 async fn remove(&self, key: &str) -> Result<()>;
20
21 async fn disconnect(&self) -> Result<()>;
23
24 async fn check_health(&self) -> Result<()> {
26 Ok(())
28 }
29
30 async fn ttl(&self, key: &str) -> Result<Option<Duration>>;
31}