use std::time::Duration;
use async_trait::async_trait;
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
pub trait CacheBackend: Send + Sync + 'static {
async fn get(&self, key: &str) -> Option<Vec<u8>>;
async fn put(&self, key: &str, value: Vec<u8>, ttl: Option<Duration>);
}
#[derive(Debug, Default, Clone, Copy)]
pub struct NoopCache;
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
impl CacheBackend for NoopCache {
async fn get(&self, _key: &str) -> Option<Vec<u8>> {
None
}
async fn put(&self, _key: &str, _value: Vec<u8>, _ttl: Option<Duration>) {}
}