fix: 修复账号列表首次加载窗口费用显示 $0.00

lite 模式下从快照缓存读取窗口费用,非 lite 模式查询后写入缓存
This commit is contained in:
shaw
2026-03-06 10:23:22 +08:00
parent 63a8c76946
commit 491a744481
2 changed files with 65 additions and 24 deletions

View File

@@ -0,0 +1,25 @@
package admin
import (
"strconv"
"strings"
"time"
)
var accountWindowCostCache = newSnapshotCache(30 * time.Second)
func buildWindowCostCacheKey(accountIDs []int64) string {
if len(accountIDs) == 0 {
return "accounts_window_cost_empty"
}
var b strings.Builder
b.Grow(len(accountIDs) * 6)
_, _ = b.WriteString("accounts_window_cost:")
for i, id := range accountIDs {
if i > 0 {
_ = b.WriteByte(',')
}
_, _ = b.WriteString(strconv.FormatInt(id, 10))
}
return b.String()
}