优化代码

This commit is contained in:
刘祥超
2023-08-08 15:39:00 +08:00
parent f4258ed00e
commit 075c11a3cf
22 changed files with 27 additions and 53 deletions

View File

@@ -1276,13 +1276,6 @@ func (this *FileStorage) increaseHit(key string, hash string, reader Reader) {
this.hotMapLocker.Lock()
hotItem, ok := this.hotMap[key]
// 限制热点数据存活时间
var unixTime = time.Now().Unix()
var expiresAt = reader.ExpiresAt()
if expiresAt <= 0 || expiresAt > unixTime+HotItemLifeSeconds {
expiresAt = unixTime + HotItemLifeSeconds
}
if ok {
hotItem.Hits++
} else if len(this.hotMap) < HotItemSize { // 控制数量