Chore: Add go-redis v8 dependency (#39442)

* adds redis v8 client dependency

* remove go-redis v5 dependency
This commit is contained in:
Todd Treece
2021-09-20 16:21:59 -04:00
committed by GitHub
parent ad3c7529b0
commit 1781c8ec7d
7 changed files with 34 additions and 20 deletions

View File

@@ -1,15 +1,16 @@
package remotecache
import (
"context"
"crypto/tls"
"fmt"
"strconv"
"strings"
"time"
"github.com/go-redis/redis/v8"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util/errutil"
redis "gopkg.in/redis.v5"
)
const redisCacheType = "redis"
@@ -91,13 +92,13 @@ func (s *redisStorage) Set(key string, val interface{}, expires time.Duration) e
if err != nil {
return err
}
status := s.c.Set(key, string(value), expires)
status := s.c.Set(context.TODO(), key, string(value), expires)
return status.Err()
}
// Get gets value by given key in session.
func (s *redisStorage) Get(key string) (interface{}, error) {
v := s.c.Get(key)
v := s.c.Get(context.TODO(), key)
item := &cachedItem{}
err := decodeGob([]byte(v.Val()), item)
@@ -113,6 +114,6 @@ func (s *redisStorage) Get(key string) (interface{}, error) {
// Delete delete a key from session.
func (s *redisStorage) Delete(key string) error {
cmd := s.c.Del(key)
cmd := s.c.Del(context.TODO(), key)
return cmd.Err()
}