use moka::sync::Cache;
use std::time::Duration;
pub struct OptimizedCache {
cache: Cache<String, bool>,
}
impl OptimizedCache {
pub fn new(max_capacity: u64) -> Self {
Self {
cache: Cache::builder()
.max_capacity(max_capacity)
.time_to_live(Duration::from_secs(3600))
.build()
}
}
pub fn get(&self, key: &str) -> Option<bool> {
self.cache.get(key)
}
pub fn insert(&self, key: String, value: bool) {
self.cache.insert(key, value);
}
}