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 }