1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-08-26 20:18:13 +02:00

Refactor to use the new redis.Key,redis.Namespace and redis.Channel types.

This commit is contained in:
Henrik Hautakoski 2023-01-06 17:06:27 +01:00
parent 61beca435c
commit 13c8ed7692
3 changed files with 18 additions and 26 deletions

View file

@ -2,7 +2,6 @@ package redis
import (
"context"
"strings"
"time"
_redis "github.com/go-redis/redis/v8"
@ -14,8 +13,6 @@ var redis_pipe _redis.Pipeliner
var redisCtx = context.Background()
var prefix []string
func Connect(addr string, password string, db int) error {
rdb = _redis.NewClient(&_redis.Options{
Addr: addr,
@ -32,16 +29,6 @@ func Client() *_redis.Client {
return rdb
}
func SetPrefix(components ...string) {
prefix = components
}
func Key(components ...string) string {
namespace := strings.Join(prefix, ".")
channel := strings.Join(components, ".")
return namespace + "::" + channel
}
func Get(key string) *_redis.StringCmd {
return rdb.Get(redisCtx, key)
}