1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-17 04:30:03 +02:00
thalos/internal/cache/redis_store.go

35 lines
639 B
Go

package cache
import (
"context"
"time"
"github.com/go-redis/cache/v9"
)
type RedisStore struct {
c *cache.Cache
}
func NewRedisStore(options *cache.Options) *RedisStore {
return &RedisStore{
c: cache.New(options),
}
}
func (s *RedisStore) Get(ctx context.Context, key string, value interface{}) error {
return s.c.Get(ctx, key, value)
}
func (s *RedisStore) Has(ctx context.Context, key string) bool {
return s.c.Exists(ctx, key)
}
func (s *RedisStore) Set(ctx context.Context, key string, value any, ttl time.Duration) error {
return s.c.Set(&cache.Item{
Ctx: ctx,
Key: key,
Value: value,
TTL: ttl,
})
}