perf: reduce gateway db pressure under load

This commit is contained in:
elky
2026-06-22 00:08:48 +08:00
parent 541cc197c4
commit f75894acbb
52 changed files with 4440 additions and 252 deletions
+7
View File
@@ -1,18 +1,21 @@
use std::time::Duration;
use aether_cache::ExpiringMap;
use tokio::sync::{Mutex, MutexGuard};
const MAX_ENTRIES: usize = 512;
#[derive(Debug)]
pub(crate) struct SystemConfigCache {
entries: ExpiringMap<String, Option<serde_json::Value>>,
load_guard: Mutex<()>,
}
impl Default for SystemConfigCache {
fn default() -> Self {
Self {
entries: ExpiringMap::new(),
load_guard: Mutex::new(()),
}
}
}
@@ -26,6 +29,10 @@ impl SystemConfigCache {
self.entries.insert(key, value, ttl, MAX_ENTRIES);
}
pub(crate) async fn load_guard(&self) -> MutexGuard<'_, ()> {
self.load_guard.lock().await
}
pub(crate) fn clear(&self) {
self.entries.clear();
}