From 21d40b8e6929601e37c2a9cc3da5cc2ac6e1b21a Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sun, 15 Dec 2024 22:09:59 +0300 Subject: [PATCH] fixup lint Signed-off-by: Vasiliy Tolstov --- redis.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/redis.go b/redis.go index 07ee5bf..9077bc6 100755 --- a/redis.go +++ b/redis.go @@ -22,11 +22,7 @@ func (r *Store) Connect(ctx context.Context) error { } func (r *Store) Init(opts ...options.Option) error { - for _, o := range opts { - o(&r.opts) - } - - return r.configure() + return r.configure(opts...) } func (r *Store) Redis() redis.UniversalClient { @@ -237,8 +233,11 @@ func (r *Store) MWrite(ctx context.Context, keys []string, vals []interface{}, o } cmds, err := r.cli.Pipelined(ctx, func(pipe redis.Pipeliner) error { + var err error for idx := 0; idx < len(kvs); idx += 2 { - pipe.Set(ctx, kvs[idx], kvs[idx+1], options.TTL).Result() + if _, err = pipe.Set(ctx, kvs[idx], kvs[idx+1], options.TTL).Result(); err != nil { + return err + } } return nil }) @@ -335,13 +334,20 @@ func NewStore(opts ...options.Option) *Store { return &Store{opts: store.NewOptions(opts...)} } -func (r *Store) configure() error { - var redisUniversalOptions *redis.UniversalOptions - - if r.cli != nil && r.opts.Context == nil { +func (r *Store) configure(opts ...options.Option) error { + if r.cli != nil && len(opts) == 0 { return nil } + var redisUniversalOptions *redis.UniversalOptions + var err error + + for _, o := range opts { + if err = o(r.opts); err != nil { + return err + } + } + if r.opts.Context != nil { if c, ok := r.opts.Context.Value(universalConfigKey{}).(*redis.UniversalOptions); ok { redisUniversalOptions = c