mirror of https://github.com/1Panel-dev/1Panel
feat: 增加定时清理缓存 (#5226)
parent
90bcf464d3
commit
d38d2c617d
@ -0,0 +1,26 @@
|
||||
package job
|
||||
|
||||
import (
|
||||
"github.com/1Panel-dev/1Panel/backend/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Cache struct{}
|
||||
|
||||
func NewCacheJob() *Cache {
|
||||
return &Cache{}
|
||||
}
|
||||
|
||||
func (c *Cache) Run() {
|
||||
global.LOG.Info("run cache gc start ...")
|
||||
ticker := time.NewTicker(5 * time.Minute)
|
||||
defer ticker.Stop()
|
||||
for range ticker.C {
|
||||
again:
|
||||
err := global.CacheDb.RunValueLogGC(0.7)
|
||||
if err == nil {
|
||||
goto again
|
||||
}
|
||||
}
|
||||
global.LOG.Info("run cache gc end ...")
|
||||
}
|
Loading…
Reference in new issue