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 cache_updated( object: AnyObject, value: AnyValue, state: CacheSubstack, _operation_state: StackOperationState, stack: Arc, ) -> Result<(), OperationError> { 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().value_kind.to_string(), }; let value_kind = value.kind().value_kind; trace!( "Beginning cache update for {}::{}", object.kind(), value_kind ); state.cache.insert(cache_key, value).await; trace!( "Completed cache update for {}::{}", object.kind(), value_kind ); Ok(()) }