From bbb0c68fb0ef682a086f80c4636575e14d2e724a Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Fri, 15 Sep 2023 14:46:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8D=95=E6=AC=A1=E6=B8=85?= =?UTF-8?q?=E7=90=86LFU=E7=BC=93=E5=AD=98=E6=95=B0=E9=87=8F=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/caches/storage_file.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/caches/storage_file.go b/internal/caches/storage_file.go index bee6599..5c48843 100644 --- a/internal/caches/storage_file.go +++ b/internal/caches/storage_file.go @@ -1072,7 +1072,15 @@ func (this *FileStorage) purgeLoop() { // 磁盘空间不足时,清除老旧的缓存 if startLFU { + var maxCount = 2000 var maxLoops = 5 + + if fsutils.DiskIsFast() { + maxCount = 5000 + } else if fsutils.DiskIsExtremelyFast() { + maxCount = 10000 + } + for { maxLoops-- if maxLoops <= 0 { @@ -1091,8 +1099,8 @@ func (this *FileStorage) purgeLoop() { } // 限制单次清理的条数,防止占用太多系统资源 - if count > 2000 { - count = 2000 + if count > maxCount { + count = maxCount } remotelogs.Println("CACHE", "LFU purge policy '"+this.policy.Name+"' id: "+types.String(this.policy.Id)+", count: "+types.String(count))