mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-11-25 11:29:29 +08:00
25 lines
355 B
Go
25 lines
355 B
Go
|
|
package cache
|
||
|
|
|
||
|
|
import (
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"github.com/OpenListTeam/OpenList/v4/pkg/cron"
|
||
|
|
log "github.com/sirupsen/logrus"
|
||
|
|
)
|
||
|
|
|
||
|
|
var (
|
||
|
|
cacheGcCron *cron.Cron
|
||
|
|
gcFuncs []func()
|
||
|
|
)
|
||
|
|
|
||
|
|
func init() {
|
||
|
|
// TODO Move to bootstrap
|
||
|
|
cacheGcCron = cron.NewCron(time.Hour)
|
||
|
|
cacheGcCron.Do(func() {
|
||
|
|
log.Infof("Start cache GC")
|
||
|
|
for _, f := range gcFuncs {
|
||
|
|
f()
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|