use cache_get::get_cached; use giterated_stack::{AnyValue, SubstackBuilder}; use moka::future::Cache; use crate::cache_update::cache_updated; pub mod cache_get; pub mod cache_update; // use giterated_stack::{ObjectValuePair, SubstackBuilder}; // use moka::future::Cache; // use serde_json::Value; #[derive(Hash, PartialEq, Eq)] pub struct CacheKey { object: String, value_name: String, } #[derive(Clone)] pub struct CacheSubstack { cache: Cache, } impl Default for CacheSubstack { fn default() -> Self { Self { cache: Cache::new(20_000), } } } impl CacheSubstack { pub fn into_substack(self) -> SubstackBuilder { let mut stack = SubstackBuilder::new(self); stack.value_change(cache_updated); stack.dynamic_value(get_cached); stack } }