You've already forked VptPassiveAdapter
fix(s3): 解决缓存清理时的类型断言错误
- 添加类型检查避免非 cacheItem 类型值导致的 panic - 跳过 lock_xxx 对应的 *sync.Mutex 类型值 - 保持原有缓存过期清理逻辑不变
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"ZhenTuLocalPassiveAdapter/logger"
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
@@ -203,7 +203,11 @@ func init() {
|
||||
func cleanupCache() {
|
||||
var keysToDelete []interface{}
|
||||
s3Cache.Range(func(key, value interface{}) bool {
|
||||
item := value.(cacheItem)
|
||||
// 类型检查:跳过非 cacheItem 类型的值(例如 lock_xxx 对应的 *sync.Mutex)
|
||||
item, ok := value.(cacheItem)
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
if time.Now().After(item.expires) {
|
||||
keysToDelete = append(keysToDelete, key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user