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

* adds redis v8 client dependency

* remove go-redis v5 dependency

(cherry picked from commit 1781c8ec7d)

Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2021-09-20 22:52:18 +02:00
committed by GitHub
co-authored by Todd Treece
parent 9ae43a7aaa
commit 88ea42ab9c
7 changed files with 34 additions and 20 deletions
@@ -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) {