From fe98f4a5f9c883a254da5e20fe78ebc6015408c1 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 13 May 2020 14:45:16 +0300 Subject: [PATCH] store/redis: use operation options Signed-off-by: Vasiliy Tolstov --- redis.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/redis.go b/redis.go index 5efa206..b5bf641 100644 --- a/redis.go +++ b/redis.go @@ -26,9 +26,16 @@ func (r *rkv) Close() error { } func (r *rkv) Read(key string, opts ...store.ReadOption) ([]*store.Record, error) { + options := store.ReadOptions{} + options.Table = r.options.Table + + for _, o := range opts { + o(&options) + } + records := make([]*store.Record, 0, 1) - rkey := fmt.Sprintf("%s%s", r.options.Table, key) + rkey := fmt.Sprintf("%s%s", options.Table, key) val, err := r.Client.Get(rkey).Bytes() if err != nil && err == redis.Nil { @@ -75,7 +82,7 @@ func (r *rkv) Write(record *store.Record, opts ...store.WriteOption) error { o(&options) } - rkey := fmt.Sprintf("%s%s", r.options.Table, record.Key) + rkey := fmt.Sprintf("%s%s", options.Table, record.Key) return r.Client.Set(rkey, record.Value, record.Expiry).Err() }