use cache::Expiration; use crate::state::{AppInternalState, AppState}; use serde::de::DeserializeOwned; use serde::Serialize; pub async fn projects_cache( app_state: &mut AppInternalState, key: String, ) -> Option { app_state .cache .get(format!("projects:{key}")) .await .unwrap_or(None) } pub fn set_projects_cache(app_state: &AppState, key: String, value: T, expiration: Expiration) where T: Serialize + DeserializeOwned + Send + Sync + 'static, { let app_state = app_state.clone(); tokio::spawn(async move { let mut s = app_state.lock().await; let _ = s .cache .set( format!("projects:{key}"), &value, Some(expiration), None, false, ) .await; }); }