自动在空闲时间执行定时任务

This commit is contained in:
GoEdgeLab
2024-04-17 13:10:55 +08:00
parent e7b70dd9b3
commit 7af6bfd536
13 changed files with 218 additions and 49 deletions

View File

@@ -5,6 +5,7 @@ package cachehits
import (
"github.com/TeaOSLab/EdgeNode/internal/goman"
"github.com/TeaOSLab/EdgeNode/internal/utils/fasttime"
"github.com/TeaOSLab/EdgeNode/internal/utils/idles"
memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem"
"github.com/iwind/TeaGo/Tea"
"sync"
@@ -58,7 +59,7 @@ func NewStat(goodRatio uint64) *Stat {
}
func (this *Stat) init() {
for range this.ticker.C {
idles.RunTicker(this.ticker, func() {
var currentTime = fasttime.Now().Unix()
this.mu.RLock()
@@ -73,7 +74,7 @@ func (this *Stat) init() {
}
}
this.mu.RUnlock()
}
})
}
func (this *Stat) IncreaseCached(category string) {