mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 09:38:02 +00:00
fix: 修复总费用被重置的bug
This commit is contained in:
@@ -714,7 +714,7 @@ class RedisClient {
|
||||
const dailyKey = `usage:cost:daily:${keyId}:${today}`
|
||||
const monthlyKey = `usage:cost:monthly:${keyId}:${currentMonth}`
|
||||
const hourlyKey = `usage:cost:hourly:${keyId}:${currentHour}`
|
||||
const totalKey = `usage:cost:total:${keyId}`
|
||||
const totalKey = `usage:cost:total:${keyId}` // 总费用键 - 永不过期,持续累加
|
||||
|
||||
logger.debug(
|
||||
`💰 Incrementing cost for ${keyId}, amount: $${amount}, date: ${today}, dailyKey: ${dailyKey}`
|
||||
@@ -724,8 +724,8 @@ class RedisClient {
|
||||
this.client.incrbyfloat(dailyKey, amount),
|
||||
this.client.incrbyfloat(monthlyKey, amount),
|
||||
this.client.incrbyfloat(hourlyKey, amount),
|
||||
this.client.incrbyfloat(totalKey, amount),
|
||||
// 设置过期时间
|
||||
this.client.incrbyfloat(totalKey, amount), // ✅ 累加到总费用(永不过期)
|
||||
// 设置过期时间(注意:totalKey 不设置过期时间,保持永久累计)
|
||||
this.client.expire(dailyKey, 86400 * 30), // 30天
|
||||
this.client.expire(monthlyKey, 86400 * 90), // 90天
|
||||
this.client.expire(hourlyKey, 86400 * 7) // 7天
|
||||
|
||||
Reference in New Issue
Block a user