mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Add go-redis v8 dependency (#39442)
* adds redis v8 client dependency * remove go-redis v5 dependency
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/stretchr/testify/assert"
|
||||
redis "gopkg.in/redis.v5"
|
||||
)
|
||||
|
||||
func Test_parseRedisConnStr(t *testing.T) {
|
||||
|
||||
@@ -37,11 +37,11 @@ import (
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
|
||||
"github.com/centrifugal/centrifuge"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/gobwas/glob"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/live"
|
||||
"gopkg.in/macaron.v1"
|
||||
"gopkg.in/redis.v5"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -146,7 +146,7 @@ func ProvideService(plugCtxProvider *plugincontext.Provider, cfg *setting.Cfg, r
|
||||
redisClient := redis.NewClient(&redis.Options{
|
||||
Addr: g.Cfg.LiveHAEngineAddress,
|
||||
})
|
||||
cmd := redisClient.Ping()
|
||||
cmd := redisClient.Ping(context.TODO())
|
||||
if _, err := cmd.Result(); err != nil {
|
||||
return nil, fmt.Errorf("error pinging Redis: %v", err)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package managedstream
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"sync"
|
||||
@@ -8,8 +9,8 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/live/orgchannel"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
"gopkg.in/redis.v5"
|
||||
)
|
||||
|
||||
// RedisFrameCache ...
|
||||
@@ -43,7 +44,7 @@ func (c *RedisFrameCache) GetActiveChannels(orgID int64) (map[string]json.RawMes
|
||||
|
||||
func (c *RedisFrameCache) GetFrame(orgID int64, channel string) (json.RawMessage, bool, error) {
|
||||
key := getCacheKey(orgchannel.PrependOrgID(orgID, channel))
|
||||
cmd := c.redisClient.HGetAll(key)
|
||||
cmd := c.redisClient.HGetAll(context.TODO(), key)
|
||||
result, err := cmd.Result()
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
@@ -73,14 +74,16 @@ func (c *RedisFrameCache) Update(orgID int64, channel string, jsonFrame data.Fra
|
||||
pipe := c.redisClient.TxPipeline()
|
||||
defer func() { _ = pipe.Close() }()
|
||||
|
||||
pipe.HGetAll(key)
|
||||
pipe.HMSet(key, map[string]string{
|
||||
ctx := context.TODO()
|
||||
|
||||
pipe.HGetAll(ctx, key)
|
||||
pipe.HMSet(ctx, key, map[string]string{
|
||||
"schema": stringSchema,
|
||||
"frame": string(jsonFrame.Bytes(data.IncludeAll)),
|
||||
})
|
||||
pipe.Expire(key, frameCacheTTL)
|
||||
pipe.Expire(ctx, key, frameCacheTTL)
|
||||
|
||||
replies, err := pipe.Exec()
|
||||
replies, err := pipe.Exec(ctx)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ package managedstream
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/stretchr/testify/require"
|
||||
"gopkg.in/redis.v5"
|
||||
)
|
||||
|
||||
func TestRedisCacheStorage(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user