From a57777e7cd1411d7877a84f50bac1b52712fe31d Mon Sep 17 00:00:00 2001 From: Victor_Jay Date: Sun, 31 May 2026 12:18:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Redis=20=E6=A8=A1=E5=BC=8F=E4=B8=8B?= =?UTF-8?q?=E6=B4=BB=E8=B7=83=E4=BC=9A=E8=AF=9D=E6=95=B0=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=BA=200=EF=BC=8C=E5=BA=94=E4=B8=BA?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - FallbackStore.Metrics() 未设置 ActiveCount 时 Go 默认值为 0,模板误显示 0 - 修复:Redis 健康时显式设置 ActiveCount=-1,与 RedisStore.Metrics() 一致 - 模板 ge .ActiveSessions 0 判断自动隐藏,Redis 模式不统计会话数(代价高) --- internal/session/fallback_store.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/internal/session/fallback_store.go b/internal/session/fallback_store.go index 7c69598..2dcfed9 100644 --- a/internal/session/fallback_store.go +++ b/internal/session/fallback_store.go @@ -250,24 +250,19 @@ func (fs *FallbackStore) Metrics() StoreMetrics { isDegraded := fs.degraded.Load() m := StoreMetrics{ - Type: "redis", - Healthy: healthy, + Type: "redis", + Healthy: healthy, + ActiveCount: -1, // Redis 模式不统计活跃会话数(代价高),模板 ge 0 判断自动隐藏 } if !healthy { m.Type = "memory" m.Degraded = true + m.ActiveCount = fs.memory.Metrics().ActiveCount } else if isDegraded { m.Degraded = true m.DegradedNote = "Redis 已恢复,但存在历史降级记录(重启后清除)" } - // 活跃会话数:Redis 模式不统计(代价高),Memory 模式可从 memory store 获取 - if !healthy { - if memMetrics := fs.memory.Metrics(); memMetrics.Type == "memory" { - m.ActiveCount = memMetrics.ActiveCount - } - } - return m }