add: shared structs, caching services, import task change

This commit is contained in:
wymiller committed 2026-11-09 00:04:22 -05:00
1 parent b64d5ba0ad
commit 5cb5dd8eb8
41 files changed
+875 -770

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
use cache::Expiration;
use crate::state::{AppInternalState, AppState};
use serde::de::DeserializeOwned;
use serde::Serialize;
pub async fn projects_cache<T: DeserializeOwned>(
app_state: &mut AppInternalState,
key: String,
) -> Option<T> {
app_state
.cache
.get(format!("projects:{key}"))
.await
.unwrap_or(None)
}
pub fn set_projects_cache<T>(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;
});
}