mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-01-03 22:06:37 +08:00
清理LFU缓存时日志打印消耗时间/删除缓存分区信息文件前判断文件是否存在
This commit is contained in:
@@ -1129,11 +1129,7 @@ func (this *FileStorage) purgeLoop() {
|
||||
count = maxCount
|
||||
}
|
||||
|
||||
var prefix = ""
|
||||
if requireFullLFU {
|
||||
prefix = "fully "
|
||||
}
|
||||
remotelogs.Println("CACHE", prefix+"LFU purge policy '"+this.policy.Name+"' id: "+types.String(this.policy.Id)+", count: "+types.String(count))
|
||||
var before = time.Now()
|
||||
err := this.list.PurgeLFU(count, func(hash string) error {
|
||||
path, _ := this.hashPath(hash)
|
||||
fsutils.WriteBegin()
|
||||
@@ -1145,6 +1141,13 @@ func (this *FileStorage) purgeLoop() {
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
var prefix = ""
|
||||
if requireFullLFU {
|
||||
prefix = "fully "
|
||||
}
|
||||
remotelogs.Println("CACHE", prefix+"LFU purge policy '"+this.policy.Name+"' id: "+types.String(this.policy.Id)+", count: "+types.String(count)+", cost:"+fmt.Sprintf("%.2fms", time.Since(before).Seconds()*1000))
|
||||
|
||||
if err != nil {
|
||||
remotelogs.Warn("CACHE", "purge file storage in LFU failed: "+err.Error())
|
||||
}
|
||||
@@ -1399,7 +1402,11 @@ func (this *FileStorage) removeCacheFile(path string) error {
|
||||
if openFileCache != nil {
|
||||
openFileCache.Close(partialPath)
|
||||
}
|
||||
_ = os.Remove(partialPath)
|
||||
|
||||
_, statErr := os.Stat(partialPath)
|
||||
if statErr == nil {
|
||||
_ = os.Remove(partialPath)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user