// use std::sync::Arc; // use giterated_models::error::OperationError; // use giterated_stack::GiteratedStack; // use serde_json::Value; // use crate::{cache_update::AnyObject, CacheSubstack}; // pub async fn try_value_get( // object: AnyObject<'_>, // value_name: &str, // cache: CacheSubstack, // stack: Arc, // ) -> Result> { // todo!() // } use std::sync::Arc; use giterated_models::error::OperationError; use giterated_stack::{AnyObject, AnyValue, GiteratedStack, StackOperationState}; use tracing::trace; use crate::{CacheKey, CacheSubstack}; pub async fn get_cached( object: AnyObject, value_kind: String, cache: CacheSubstack, _operation_state: StackOperationState, stack: Arc, ) -> Result> { let object_meta = stack .metadata .objects .get(object.kind()) .ok_or_else(|| OperationError::Unhandled)?; let object_str = (object_meta.to_str)(object.clone()); let cache_key = CacheKey { object: object_str, value_name: value_kind.clone(), }; trace!("Check cache for {}::{}", object.kind(), value_kind); if let Some(cached_value) = cache.cache.get(&cache_key).await { trace!("Found cached for {}::{}", object.kind(), value_kind); Ok(cached_value.clone()) } else { trace!("Nothing cached for {}::{}", object.kind(), value_kind); Err(OperationError::Unhandled) } }