mirror of
https://github.com/eosswedenorg/thalos
synced 2026-07-04 12:03:41 +02:00
cmd/thalos/server.go: use factory and config to create cache store
This commit is contained in:
parent
ebbaf6e2c1
commit
8a938c3f9e
1 changed files with 7 additions and 6 deletions
|
|
@ -26,7 +26,6 @@ import (
|
||||||
driver "github.com/eosswedenorg/thalos/internal/driver/redis"
|
driver "github.com/eosswedenorg/thalos/internal/driver/redis"
|
||||||
. "github.com/eosswedenorg/thalos/internal/log"
|
. "github.com/eosswedenorg/thalos/internal/log"
|
||||||
. "github.com/eosswedenorg/thalos/internal/server"
|
. "github.com/eosswedenorg/thalos/internal/server"
|
||||||
redis_cache "github.com/go-redis/cache/v9"
|
|
||||||
"github.com/nikoksr/notify"
|
"github.com/nikoksr/notify"
|
||||||
"github.com/nikoksr/notify/service/telegram"
|
"github.com/nikoksr/notify/service/telegram"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
|
|
@ -346,12 +345,14 @@ func serverCmd(cmd *cobra.Command, args []string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cache.RegisterFactory("redis", cache.NewRedisFactory(rdb))
|
||||||
|
|
||||||
// Setup cache storage
|
// Setup cache storage
|
||||||
cacheStore := cache.NewRedisStore(&redis_cache.Options{
|
cacheStore, err := cache.Make(conf.Cache.Storage, conf.Cache.Options)
|
||||||
Redis: rdb,
|
if err != nil {
|
||||||
// Cache 10k keys for 10 minutes.
|
log.WithError(err).Fatal("Failed to setup cache")
|
||||||
LocalCache: redis_cache.NewTinyLFU(10000, 10*time.Minute),
|
return
|
||||||
})
|
}
|
||||||
|
|
||||||
// Setup general cache
|
// Setup general cache
|
||||||
cache := cache.NewCache("thalos::cache::instance::"+conf.Name, cacheStore)
|
cache := cache.NewCache("thalos::cache::instance::"+conf.Name, cacheStore)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue