mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-15 23:26:36 +08:00
在节点重新实现缓存策略和WAF策略
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/events"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/logs"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
@@ -82,7 +82,7 @@ func (this *FileStorage) Init() error {
|
||||
}
|
||||
|
||||
cost := time.Since(before).Seconds() * 1000
|
||||
logs.Println("CACHE", "init policy "+strconv.FormatInt(this.policy.Id, 10)+", cost: "+fmt.Sprintf("%.2f", cost)+" ms, count: "+strconv.Itoa(count)+", size: "+fmt.Sprintf("%.3f", float64(size)/1024/1024)+" M")
|
||||
remotelogs.Println("CACHE", "init policy "+strconv.FormatInt(this.policy.Id, 10)+", cost: "+fmt.Sprintf("%.2f", cost)+" ms, count: "+strconv.Itoa(count)+", size: "+fmt.Sprintf("%.3f", float64(size)/1024/1024)+" M")
|
||||
}()
|
||||
|
||||
// 配置
|
||||
@@ -546,7 +546,7 @@ func (this *FileStorage) initList() error {
|
||||
item, err := this.decodeFile(path)
|
||||
if err != nil {
|
||||
if err != ErrNotFound {
|
||||
logs.Error("CACHE", "decode path '"+path+"': "+err.Error())
|
||||
remotelogs.Error("CACHE", "decode path '"+path+"': "+err.Error())
|
||||
}
|
||||
continue
|
||||
}
|
||||
@@ -559,7 +559,7 @@ func (this *FileStorage) initList() error {
|
||||
// 启动定时清理任务
|
||||
this.ticker = utils.NewTicker(30 * time.Second)
|
||||
events.On(events.EventQuit, func() {
|
||||
logs.Println("CACHE", "quit clean timer")
|
||||
remotelogs.Println("CACHE", "quit clean timer")
|
||||
var ticker = this.ticker
|
||||
if ticker != nil {
|
||||
ticker.Stop()
|
||||
@@ -642,7 +642,7 @@ func (this *FileStorage) purgeLoop() {
|
||||
path := this.hashPath(hash)
|
||||
err := os.Remove(path)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
logs.Error("CACHE", "purge '"+path+"' error: "+err.Error())
|
||||
remotelogs.Error("CACHE", "purge '"+path+"' error: "+err.Error())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user