perf(cache): run tag post invalidations concurrently

This commit is contained in:
xfy 2026-06-17 16:59:29 +08:00
parent 2d8f1e0d98
commit 7bd02d0ea9
3 changed files with 8 additions and 3 deletions

1
Cargo.lock generated
View File

@ -5397,6 +5397,7 @@ dependencies = [
"deadpool-postgres",
"dioxus",
"dotenvy",
"futures",
"governor",
"hex",
"http",

View File

@ -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",
]

View File

@ -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;
}
/// 清空所有文章相关缓存(列表、标签、单篇、统计、标签文章)。