fix(cache): drain pending removals during clear (#4759)

This commit is contained in:
Zhengchao An
2026-07-12 09:46:13 +08:00
committed by GitHub
parent b540c7e2d0
commit 3832f1d270
+8 -1
View File
@@ -330,8 +330,15 @@ impl MokaBackend {
/// index). Rare admin `clear()` path only.
pub async fn clear(&self) -> ObjectDataCacheInvalidationResult {
let removed = self.index.remove_matching(|_| true).await.len();
self.cache.invalidate_all();
self.cache.run_pending_tasks().await;
self.cache.invalidate_all();
for _ in 0..8 {
self.cache.run_pending_tasks().await;
if self.cache.entry_count() == 0 {
break;
}
tokio::task::yield_now().await;
}
Self::invalidation_result(removed)
}