More stuff
This commit is contained in:
parent
71beed7eb3
commit
9a7e420c83
7 changed files with 63 additions and 33 deletions
12
storage/cache/cache.go
vendored
12
storage/cache/cache.go
vendored
|
@ -12,6 +12,7 @@ import (
|
|||
ristretto_store "github.com/eko/gocache/store/ristretto/v4"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"github.com/rs/zerolog/log"
|
||||
"gitlab.com/mstarongitlab/linstrom/config"
|
||||
)
|
||||
|
||||
type Cache struct {
|
||||
|
@ -37,7 +38,9 @@ func NewCache(maxSize int64, redisUrl *string) (*Cache, error) {
|
|||
}
|
||||
ristrettoStore := ristretto_store.NewRistretto(
|
||||
ristrettoCache,
|
||||
store.WithExpiration(time.Second*10),
|
||||
store.WithExpiration(
|
||||
time.Second*time.Duration(config.GlobalConfig.Storage.MaxInMemoryCacheSize),
|
||||
),
|
||||
)
|
||||
|
||||
var cacheManager *cache.ChainCache[[]byte]
|
||||
|
@ -47,7 +50,12 @@ func NewCache(maxSize int64, redisUrl *string) (*Cache, error) {
|
|||
return nil, err
|
||||
}
|
||||
redisClient := redis.NewClient(opts)
|
||||
redisStore := redis_store.NewRedis(redisClient, store.WithExpiration(time.Minute))
|
||||
redisStore := redis_store.NewRedis(
|
||||
redisClient,
|
||||
store.WithExpiration(
|
||||
time.Second*time.Duration(*config.GlobalConfig.Storage.MaxRedisCacheTTL),
|
||||
),
|
||||
)
|
||||
cacheManager = cache.NewChain(
|
||||
cache.New[[]byte](ristrettoStore),
|
||||
cache.New[[]byte](redisStore),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue