use std::time::Duration;
use bytes::Bytes;
use derive_more::{Debug, Display, Error};
#[derive(Debug, Display, Error)]
#[display("cache error: {_0}")]
#[error(ignore)]
pub struct CacheError(pub String);
pub trait Cache: Send + Sync + 'static {
fn get(
&self,
key: &str,
) -> impl std::future::Future<Output = Result<Option<Bytes>, CacheError>> + Send;
fn put(
&self,
key: &str,
value: Bytes,
ttl: Duration,
) -> impl std::future::Future<Output = Result<(), CacheError>> + Send;
fn delete(&self, key: &str)
-> impl std::future::Future<Output = Result<(), CacheError>> + Send;
}