bootstrap

This commit is contained in:
微凉
2021-10-27 22:45:36 +08:00
parent 9644cc98c3
commit 55f683b12d
18 changed files with 311 additions and 133 deletions

20
bootstrap/cache.go Normal file
View File

@ -0,0 +1,20 @@
package bootstrap
import (
"github.com/Xhofe/alist/conf"
"github.com/allegro/bigcache/v3"
"github.com/eko/gocache/v2/cache"
"github.com/eko/gocache/v2/store"
log "github.com/sirupsen/logrus"
"time"
)
// InitCache init cache
func InitCache() {
log.Infof("init cache...")
bigCacheConfig := bigcache.DefaultConfig(60 * time.Minute)
bigCacheConfig.HardMaxCacheSize = 512
bigCacheClient, _ := bigcache.NewBigCache(bigCacheConfig)
bigCacheStore := store.NewBigcache(bigCacheClient, nil)
conf.Cache = cache.New(bigCacheStore)
}