use std::sync::Arc;
use crate::{predicates::Predicate, CacheError};
use async_trait::async_trait;
#[cfg(feature = "derive")]
#[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
pub use hitbox_derive::Cacheable;
pub use hitbox_backend::CacheableResponse;
#[async_trait]
pub trait Cacheable {
async fn cache_key(&self) -> Result<String, CacheError>;
fn cache_key_prefix(&self) -> String;
fn cache_ttl(&self) -> u32 {
60
}
fn cache_stale_ttl(&self) -> u32 {
let ttl = self.cache_ttl();
let stale_time = 5;
if ttl >= stale_time {
ttl - stale_time
} else {
0
}
}
fn cache_version(&self) -> u32 {
0
}
}