diff --git a/Cargo.lock b/Cargo.lock index 5044243..05e4cc3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5397,6 +5397,7 @@ dependencies = [ "deadpool-postgres", "dioxus", "dotenvy", + "futures", "governor", "hex", "http", diff --git a/Cargo.toml b/Cargo.toml index f86de3b..db8bda4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,7 @@ zenwebp = { version = "0.3", optional = true } moka = { version = "0.12", features = ["future"], optional = true } governor = { version = "0.8", optional = true } md-5 = { version = "0.10", optional = true } +futures = { version = "0.3", optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] web-sys = { version = "0.3", features = ["Document", "Window", "Storage", "Element", "HtmlElement", "DomTokenList", "MediaQueryList", "HtmlImageElement", "MouseEvent", "KeyboardEvent", "Node", "EventTarget", "Navigator"] } @@ -82,4 +83,5 @@ server = [ "dep:moka", "dep:governor", "dep:md-5", + "dep:futures", ] diff --git a/src/cache.rs b/src/cache.rs index ddf617e..44e98da 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -291,9 +291,11 @@ pub fn invalidate_post_stats() { /// 按标签批量失效文章列表缓存。 #[cfg(feature = "server")] pub async fn invalidate_tag_posts_for(tags: &[String]) { - for tag in tags { - invalidate_posts_by_tag(tag).await; - } + let futures: Vec<_> = tags + .iter() + .map(|tag| invalidate_posts_by_tag(tag)) + .collect(); + let _ = futures::future::join_all(futures).await; } /// 清空所有文章相关缓存(列表、标签、单篇、统计、标签文章)。