|
|
@@ -2,9 +2,9 @@ package redis
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"reflect"
|
|
|
|
"reflect"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"sync/atomic"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
goredis "github.com/redis/go-redis/v9"
|
|
|
|
goredis "github.com/redis/go-redis/v9"
|
|
|
@@ -55,19 +55,22 @@ var (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type Store struct {
|
|
|
|
type Store struct {
|
|
|
|
opts store.Options
|
|
|
|
opts store.Options
|
|
|
|
cli goredis.UniversalClient
|
|
|
|
cli goredis.UniversalClient
|
|
|
|
done chan struct{}
|
|
|
|
done chan struct{}
|
|
|
|
pool *pool.StringsPool
|
|
|
|
pool *pool.StringsPool
|
|
|
|
|
|
|
|
isConnected atomic.Int32
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *Store) Connect(ctx context.Context) error {
|
|
|
|
func (r *Store) Connect(ctx context.Context) error {
|
|
|
|
if r.cli == nil {
|
|
|
|
if r.cli == nil {
|
|
|
|
return store.ErrNotConnected
|
|
|
|
return store.ErrNotConnected
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err := r.cli.Ping(ctx).Err()
|
|
|
|
if r.opts.LazyConnect {
|
|
|
|
setSpanError(ctx, err)
|
|
|
|
return nil
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return r.connect(ctx)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *Store) Init(opts ...store.Option) error {
|
|
|
|
func (r *Store) Init(opts ...store.Option) error {
|
|
|
@@ -108,7 +111,9 @@ func (r *Store) Disconnect(ctx context.Context) error {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
if r.cli != nil {
|
|
|
|
if r.cli != nil {
|
|
|
|
err = r.cli.Close()
|
|
|
|
if err = r.cli.Close(); err != nil {
|
|
|
|
|
|
|
|
r.isConnected.Store(0)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(r.done)
|
|
|
|
close(r.done)
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@@ -116,11 +121,13 @@ func (r *Store) Disconnect(ctx context.Context) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *Store) Exists(ctx context.Context, key string, opts ...store.ExistsOption) error {
|
|
|
|
func (r *Store) Exists(ctx context.Context, key string, opts ...store.ExistsOption) error {
|
|
|
|
|
|
|
|
if err := r.connect(ctx); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
b := r.pool.Get()
|
|
|
|
b := r.pool.Get()
|
|
|
|
defer r.pool.Put(b)
|
|
|
|
defer r.pool.Put(b)
|
|
|
|
options := store.NewExistsOptions(opts...)
|
|
|
|
options := store.NewExistsOptions(opts...)
|
|
|
|
labels := make([]string, 0, 6)
|
|
|
|
|
|
|
|
labels = append(labels, "name", options.Name, "statement", "exists")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
timeout := r.opts.Timeout
|
|
|
|
timeout := r.opts.Timeout
|
|
|
|
if options.Timeout > 0 {
|
|
|
|
if options.Timeout > 0 {
|
|
|
@@ -135,22 +142,21 @@ func (r *Store) Exists(ctx context.Context, key string, opts ...store.ExistsOpti
|
|
|
|
|
|
|
|
|
|
|
|
rkey := r.getKey(b, r.opts.Namespace, options.Namespace, key)
|
|
|
|
rkey := r.getKey(b, r.opts.Namespace, options.Namespace, key)
|
|
|
|
|
|
|
|
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestInflight, labels...).Inc()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestInflight, "name", options.Name).Inc()
|
|
|
|
ts := time.Now()
|
|
|
|
ts := time.Now()
|
|
|
|
val, err := r.cli.Exists(ctx, rkey).Result()
|
|
|
|
val, err := r.cli.Exists(ctx, rkey).Result()
|
|
|
|
setSpanError(ctx, err)
|
|
|
|
setSpanError(ctx, err)
|
|
|
|
te := time.Since(ts)
|
|
|
|
te := time.Since(ts)
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestInflight, labels...).Dec()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestInflight, "name", options.Name).Dec()
|
|
|
|
|
|
|
|
r.opts.Meter.Summary(semconv.StoreRequestLatencyMicroseconds, "name", options.Name).Update(te.Seconds())
|
|
|
|
r.opts.Meter.Summary(semconv.StoreRequestLatencyMicroseconds, labels...).Update(te.Seconds())
|
|
|
|
r.opts.Meter.Histogram(semconv.StoreRequestDurationSeconds, "name", options.Name).Update(te.Seconds())
|
|
|
|
r.opts.Meter.Histogram(semconv.StoreRequestDurationSeconds, labels...).Update(te.Seconds())
|
|
|
|
if err == goredis.Nil || (err == nil && val == 0) {
|
|
|
|
if errors.Is(err, goredis.Nil) || (err == nil && val == 0) {
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, "name", options.Name, "status", "miss").Inc()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, append(labels, "status", "miss")...).Inc()
|
|
|
|
|
|
|
|
return store.ErrNotFound
|
|
|
|
return store.ErrNotFound
|
|
|
|
} else if err == nil {
|
|
|
|
} else if err == nil {
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, append(labels, "status", "hit")...).Inc()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, "name", options.Name, "status", "hit").Inc()
|
|
|
|
} else if err != nil {
|
|
|
|
} else if err != nil {
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, append(labels, "status", "failure")...).Inc()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, "name", options.Name, "status", "failure").Inc()
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -158,12 +164,14 @@ func (r *Store) Exists(ctx context.Context, key string, opts ...store.ExistsOpti
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *Store) Read(ctx context.Context, key string, val interface{}, opts ...store.ReadOption) error {
|
|
|
|
func (r *Store) Read(ctx context.Context, key string, val interface{}, opts ...store.ReadOption) error {
|
|
|
|
|
|
|
|
if err := r.connect(ctx); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
b := r.pool.Get()
|
|
|
|
b := r.pool.Get()
|
|
|
|
defer r.pool.Put(b)
|
|
|
|
defer r.pool.Put(b)
|
|
|
|
|
|
|
|
|
|
|
|
options := store.NewReadOptions(opts...)
|
|
|
|
options := store.NewReadOptions(opts...)
|
|
|
|
labels := make([]string, 0, 6)
|
|
|
|
|
|
|
|
labels = append(labels, "name", options.Name, "statement", "read")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
timeout := r.opts.Timeout
|
|
|
|
timeout := r.opts.Timeout
|
|
|
|
if options.Timeout > 0 {
|
|
|
|
if options.Timeout > 0 {
|
|
|
@@ -178,21 +186,21 @@ func (r *Store) Read(ctx context.Context, key string, val interface{}, opts ...s
|
|
|
|
|
|
|
|
|
|
|
|
rkey := r.getKey(b, r.opts.Namespace, options.Namespace, key)
|
|
|
|
rkey := r.getKey(b, r.opts.Namespace, options.Namespace, key)
|
|
|
|
|
|
|
|
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestInflight, labels...).Inc()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestInflight, "name", options.Name).Inc()
|
|
|
|
ts := time.Now()
|
|
|
|
ts := time.Now()
|
|
|
|
buf, err := r.cli.Get(ctx, rkey).Bytes()
|
|
|
|
buf, err := r.cli.Get(ctx, rkey).Bytes()
|
|
|
|
setSpanError(ctx, err)
|
|
|
|
setSpanError(ctx, err)
|
|
|
|
te := time.Since(ts)
|
|
|
|
te := time.Since(ts)
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestInflight, labels...).Dec()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestInflight, "name", options.Name).Dec()
|
|
|
|
r.opts.Meter.Summary(semconv.StoreRequestLatencyMicroseconds, labels...).Update(te.Seconds())
|
|
|
|
r.opts.Meter.Summary(semconv.StoreRequestLatencyMicroseconds, "name", options.Name).Update(te.Seconds())
|
|
|
|
r.opts.Meter.Histogram(semconv.StoreRequestDurationSeconds, labels...).Update(te.Seconds())
|
|
|
|
r.opts.Meter.Histogram(semconv.StoreRequestDurationSeconds, "name", options.Name).Update(te.Seconds())
|
|
|
|
if errors.Is(err, goredis.Nil) || (err == nil && buf == nil) {
|
|
|
|
if err == goredis.Nil || (err == nil && buf == nil) {
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, append(labels, "status", "miss")...).Inc()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, "name", options.Name, "status", "miss").Inc()
|
|
|
|
return store.ErrNotFound
|
|
|
|
return store.ErrNotFound
|
|
|
|
} else if err == nil {
|
|
|
|
} else if err == nil {
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, append(labels, "status", "hit")...).Inc()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, "name", options.Name, "status", "hit").Inc()
|
|
|
|
} else if err != nil {
|
|
|
|
} else if err != nil {
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, append(labels, "status", "failure")...).Inc()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, "name", options.Name, "status", "failure").Inc()
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -211,6 +219,10 @@ func (r *Store) Read(ctx context.Context, key string, val interface{}, opts ...s
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *Store) MRead(ctx context.Context, keys []string, vals interface{}, opts ...store.ReadOption) error {
|
|
|
|
func (r *Store) MRead(ctx context.Context, keys []string, vals interface{}, opts ...store.ReadOption) error {
|
|
|
|
|
|
|
|
if err := r.connect(ctx); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
options := store.NewReadOptions(opts...)
|
|
|
|
options := store.NewReadOptions(opts...)
|
|
|
|
|
|
|
|
|
|
|
|
timeout := r.opts.Timeout
|
|
|
|
timeout := r.opts.Timeout
|
|
|
@@ -310,6 +322,10 @@ func (r *Store) MRead(ctx context.Context, keys []string, vals interface{}, opts
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *Store) MDelete(ctx context.Context, keys []string, opts ...store.DeleteOption) error {
|
|
|
|
func (r *Store) MDelete(ctx context.Context, keys []string, opts ...store.DeleteOption) error {
|
|
|
|
|
|
|
|
if err := r.connect(ctx); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
options := store.NewDeleteOptions(opts...)
|
|
|
|
options := store.NewDeleteOptions(opts...)
|
|
|
|
|
|
|
|
|
|
|
|
timeout := r.opts.Timeout
|
|
|
|
timeout := r.opts.Timeout
|
|
|
@@ -365,12 +381,14 @@ func (r *Store) MDelete(ctx context.Context, keys []string, opts ...store.Delete
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *Store) Delete(ctx context.Context, key string, opts ...store.DeleteOption) error {
|
|
|
|
func (r *Store) Delete(ctx context.Context, key string, opts ...store.DeleteOption) error {
|
|
|
|
|
|
|
|
if err := r.connect(ctx); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
b := r.pool.Get()
|
|
|
|
b := r.pool.Get()
|
|
|
|
defer r.pool.Put(b)
|
|
|
|
defer r.pool.Put(b)
|
|
|
|
|
|
|
|
|
|
|
|
options := store.NewDeleteOptions(opts...)
|
|
|
|
options := store.NewDeleteOptions(opts...)
|
|
|
|
labels := make([]string, 0, 6)
|
|
|
|
|
|
|
|
labels = append(labels, "name", options.Name, "statement", "delete")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
timeout := r.opts.Timeout
|
|
|
|
timeout := r.opts.Timeout
|
|
|
|
if options.Timeout > 0 {
|
|
|
|
if options.Timeout > 0 {
|
|
|
@@ -383,22 +401,21 @@ func (r *Store) Delete(ctx context.Context, key string, opts ...store.DeleteOpti
|
|
|
|
defer cancel()
|
|
|
|
defer cancel()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestInflight, labels...).Inc()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestInflight, "name", options.Name).Inc()
|
|
|
|
ts := time.Now()
|
|
|
|
ts := time.Now()
|
|
|
|
err := r.cli.Del(ctx, r.getKey(b, r.opts.Namespace, options.Namespace, key)).Err()
|
|
|
|
err := r.cli.Del(ctx, r.getKey(b, r.opts.Namespace, options.Namespace, key)).Err()
|
|
|
|
te := time.Since(ts)
|
|
|
|
te := time.Since(ts)
|
|
|
|
setSpanError(ctx, err)
|
|
|
|
setSpanError(ctx, err)
|
|
|
|
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestInflight, "name", options.Name).Dec()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestInflight, labels...).Dec()
|
|
|
|
r.opts.Meter.Summary(semconv.StoreRequestLatencyMicroseconds, "name", options.Name).Update(te.Seconds())
|
|
|
|
r.opts.Meter.Summary(semconv.StoreRequestLatencyMicroseconds, labels...).Update(te.Seconds())
|
|
|
|
r.opts.Meter.Histogram(semconv.StoreRequestDurationSeconds, "name", options.Name).Update(te.Seconds())
|
|
|
|
r.opts.Meter.Histogram(semconv.StoreRequestDurationSeconds, labels...).Update(te.Seconds())
|
|
|
|
if err == goredis.Nil {
|
|
|
|
if errors.Is(err, goredis.Nil) {
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, "name", options.Name, "status", "miss").Inc()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, append(labels, "status", "miss")...).Inc()
|
|
|
|
|
|
|
|
return store.ErrNotFound
|
|
|
|
return store.ErrNotFound
|
|
|
|
} else if err == nil {
|
|
|
|
} else if err == nil {
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, append(labels, "status", "hit")...).Inc()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, "name", options.Name, "status", "hit").Inc()
|
|
|
|
} else if err != nil {
|
|
|
|
} else if err != nil {
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, append(labels, "status", "failure")...).Inc()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, "name", options.Name, "status", "failure").Inc()
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -406,6 +423,10 @@ func (r *Store) Delete(ctx context.Context, key string, opts ...store.DeleteOpti
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *Store) MWrite(ctx context.Context, keys []string, vals []interface{}, opts ...store.WriteOption) error {
|
|
|
|
func (r *Store) MWrite(ctx context.Context, keys []string, vals []interface{}, opts ...store.WriteOption) error {
|
|
|
|
|
|
|
|
if err := r.connect(ctx); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
options := store.NewWriteOptions(opts...)
|
|
|
|
options := store.NewWriteOptions(opts...)
|
|
|
|
|
|
|
|
|
|
|
|
timeout := r.opts.Timeout
|
|
|
|
timeout := r.opts.Timeout
|
|
|
@@ -489,12 +510,14 @@ func (r *Store) MWrite(ctx context.Context, keys []string, vals []interface{}, o
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *Store) Write(ctx context.Context, key string, val interface{}, opts ...store.WriteOption) error {
|
|
|
|
func (r *Store) Write(ctx context.Context, key string, val interface{}, opts ...store.WriteOption) error {
|
|
|
|
|
|
|
|
if err := r.connect(ctx); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
b := r.pool.Get()
|
|
|
|
b := r.pool.Get()
|
|
|
|
defer r.pool.Put(b)
|
|
|
|
defer r.pool.Put(b)
|
|
|
|
|
|
|
|
|
|
|
|
options := store.NewWriteOptions(opts...)
|
|
|
|
options := store.NewWriteOptions(opts...)
|
|
|
|
labels := make([]string, 0, 6)
|
|
|
|
|
|
|
|
labels = append(labels, "name", options.Name, "statement", "write")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
timeout := r.opts.Timeout
|
|
|
|
timeout := r.opts.Timeout
|
|
|
|
if options.Timeout > 0 {
|
|
|
|
if options.Timeout > 0 {
|
|
|
@@ -523,22 +546,22 @@ func (r *Store) Write(ctx context.Context, key string, val interface{}, opts ...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestInflight, labels...).Inc()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestInflight, "name", options.Name).Inc()
|
|
|
|
ts := time.Now()
|
|
|
|
ts := time.Now()
|
|
|
|
err := r.cli.Set(ctx, rkey, buf, options.TTL).Err()
|
|
|
|
err := r.cli.Set(ctx, rkey, buf, options.TTL).Err()
|
|
|
|
te := time.Since(ts)
|
|
|
|
te := time.Since(ts)
|
|
|
|
setSpanError(ctx, err)
|
|
|
|
setSpanError(ctx, err)
|
|
|
|
|
|
|
|
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestInflight, labels...).Dec()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestInflight, "name", options.Name).Dec()
|
|
|
|
r.opts.Meter.Summary(semconv.StoreRequestLatencyMicroseconds, labels...).Update(te.Seconds())
|
|
|
|
r.opts.Meter.Summary(semconv.StoreRequestLatencyMicroseconds, "name", options.Name).Update(te.Seconds())
|
|
|
|
r.opts.Meter.Histogram(semconv.StoreRequestDurationSeconds, labels...).Update(te.Seconds())
|
|
|
|
r.opts.Meter.Histogram(semconv.StoreRequestDurationSeconds, "name", options.Name).Update(te.Seconds())
|
|
|
|
if errors.Is(err, goredis.Nil) {
|
|
|
|
if err == goredis.Nil {
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, append(labels, "status", "miss")...).Inc()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, "name", options.Name, "status", "miss").Inc()
|
|
|
|
return store.ErrNotFound
|
|
|
|
return store.ErrNotFound
|
|
|
|
} else if err == nil {
|
|
|
|
} else if err == nil {
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, append(labels, "status", "hit")...).Inc()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, "name", options.Name, "status", "hit").Inc()
|
|
|
|
} else if err != nil {
|
|
|
|
} else if err != nil {
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, append(labels, "status", "failure")...).Inc()
|
|
|
|
r.opts.Meter.Counter(semconv.StoreRequestTotal, "name", options.Name, "status", "failure").Inc()
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -546,6 +569,10 @@ func (r *Store) Write(ctx context.Context, key string, val interface{}, opts ...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *Store) List(ctx context.Context, opts ...store.ListOption) ([]string, error) {
|
|
|
|
func (r *Store) List(ctx context.Context, opts ...store.ListOption) ([]string, error) {
|
|
|
|
|
|
|
|
if err := r.connect(ctx); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
b := r.pool.Get()
|
|
|
|
b := r.pool.Get()
|
|
|
|
defer r.pool.Put(b)
|
|
|
|
defer r.pool.Put(b)
|
|
|
|
|
|
|
|
|
|
|
@@ -742,3 +769,14 @@ func (r *Store) getKey(b *strings.Builder, mainNamespace string, opNamespace str
|
|
|
|
b.WriteString(key)
|
|
|
|
b.WriteString(key)
|
|
|
|
return b.String()
|
|
|
|
return b.String()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (r *Store) connect(ctx context.Context) (err error) {
|
|
|
|
|
|
|
|
if r.isConnected.Load() == 0 {
|
|
|
|
|
|
|
|
if err = r.cli.Ping(ctx).Err(); err != nil {
|
|
|
|
|
|
|
|
setSpanError(ctx, err)
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
r.isConnected.Store(1)
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|