加快缓存策略启动速度

This commit is contained in:
GoEdgeLab
2021-05-23 22:59:00 +08:00
parent ac24b6a473
commit 342568d71f

View File

@@ -579,16 +579,18 @@ func (this *FileStorage) initList() error {
return err return err
} }
dir := this.dir() // 使用异步防止阻塞主线程
go func() {
dir := this.dir()
// 清除tmp // 清除tmp
files, err := filepath.Glob(dir + "/*/*/*.cache.tmp") files, err := filepath.Glob(dir + "/*/*/*.cache.tmp")
if err != nil { if err == nil && len(files) > 0 {
return err for _, path := range files {
} _ = os.Remove(path)
for _, path := range files { }
_ = os.Remove(path) }
} }()
// 启动定时清理任务 // 启动定时清理任务
this.ticker = utils.NewTicker(30 * time.Second) this.ticker = utils.NewTicker(30 * time.Second)