fix: 修复批量更新凭证明细与缓存TTL抖动
- BatchUpdateCredentials 返回 success/failed/results 及 success_ids/failed_ids - billing jitteredTTL 改为只减不增,确保TTL不超上界 - crypto/rand 失败时随机ID降级避免 panic - OpenAI SelectAccount 失败日志去重并补充字段 - 修复两处类型断言以通过 errcheck
This commit is contained in:
@@ -22,8 +22,12 @@ const (
|
||||
|
||||
// jitteredTTL 返回带随机抖动的 TTL,防止缓存雪崩
|
||||
func jitteredTTL() time.Duration {
|
||||
jitter := time.Duration(rand.Int63n(int64(2*billingCacheJitter))) - billingCacheJitter
|
||||
return billingCacheTTL + jitter
|
||||
// 只做“减法抖动”,确保实际 TTL 不会超过 billingCacheTTL(避免上界预期被打破)。
|
||||
if billingCacheJitter <= 0 {
|
||||
return billingCacheTTL
|
||||
}
|
||||
jitter := time.Duration(rand.Int63n(int64(billingCacheJitter)))
|
||||
return billingCacheTTL - jitter
|
||||
}
|
||||
|
||||
// billingBalanceKey generates the Redis key for user balance cache.
|
||||
|
||||
Reference in New Issue
Block a user