mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-06 10:00:25 +08:00
优化单次清理LFU缓存数量逻辑
This commit is contained in:
@@ -1072,7 +1072,15 @@ func (this *FileStorage) purgeLoop() {
|
|||||||
|
|
||||||
// 磁盘空间不足时,清除老旧的缓存
|
// 磁盘空间不足时,清除老旧的缓存
|
||||||
if startLFU {
|
if startLFU {
|
||||||
|
var maxCount = 2000
|
||||||
var maxLoops = 5
|
var maxLoops = 5
|
||||||
|
|
||||||
|
if fsutils.DiskIsFast() {
|
||||||
|
maxCount = 5000
|
||||||
|
} else if fsutils.DiskIsExtremelyFast() {
|
||||||
|
maxCount = 10000
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
maxLoops--
|
maxLoops--
|
||||||
if maxLoops <= 0 {
|
if maxLoops <= 0 {
|
||||||
@@ -1091,8 +1099,8 @@ func (this *FileStorage) purgeLoop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 限制单次清理的条数,防止占用太多系统资源
|
// 限制单次清理的条数,防止占用太多系统资源
|
||||||
if count > 2000 {
|
if count > maxCount {
|
||||||
count = 2000
|
count = maxCount
|
||||||
}
|
}
|
||||||
|
|
||||||
remotelogs.Println("CACHE", "LFU purge policy '"+this.policy.Name+"' id: "+types.String(this.policy.Id)+", count: "+types.String(count))
|
remotelogs.Println("CACHE", "LFU purge policy '"+this.policy.Name+"' id: "+types.String(this.policy.Id)+", count: "+types.String(count))
|
||||||
|
|||||||
Reference in New Issue
Block a user