perf(mp): 缓存优化 — restore 条件清理 + LRU + 差异化 TTL

- auth store: clearRequestCache 仅在 user/roles/patient 变更时调用
- ResponseCache: get() 命中时 delete+set 更新 Map 顺序(真 LRU)
- 告警 API 缓存 TTL 10s,通知未读数 TTL 10s,其余保持 60s 默认
This commit is contained in:
iven
2026-05-22 12:11:59 +08:00
parent 22e33114b1
commit 5816ebb5e6
4 changed files with 15 additions and 8 deletions

View File

@@ -109,9 +109,6 @@ export const useAuthStore = create<AuthState>((set, get) => ({
setCachedPatientId(currentPatient.id);
}
// 状态有变化时清理请求缓存,避免返回过期数据
clearRequestCache();
// 跳过未变更的 set()
const cur = get();
const userChanged = cur.user?.id !== user?.id;
@@ -119,6 +116,8 @@ export const useAuthStore = create<AuthState>((set, get) => ({
const patientChanged = cur.currentPatient?.id !== currentPatient?.id;
if (!userChanged && !rolesChanged && !patientChanged) return;
// 状态有变化时清理请求缓存,避免返回过期数据
clearRequestCache();
set({ user, roles, currentPatient });
},