From e6eb55207f5c900840a98e8a2c21d98e1caac469 Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Fri, 15 Mar 2019 15:58:41 +0100 Subject: [PATCH] Redis: Add HMGet() --- redis.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/redis.go b/redis.go index d723b09f..63c57506 100644 --- a/redis.go +++ b/redis.go @@ -64,6 +64,7 @@ type RedisClient interface { XRead(a *redis.XReadArgs) *redis.XStreamSliceCmd XDel(stream string, ids ...string) *redis.IntCmd HKeys(key string) *redis.StringSliceCmd + HMGet(key string, fields ...string) *redis.SliceCmd HGetAll(key string) *redis.StringStringMapCmd TxPipelined(fn func(redis.Pipeliner) error) ([]redis.Cmder, error) Pipeline() redis.Pipeliner @@ -260,6 +261,26 @@ func (rdbw *RDBWrapper) HKeys(key string) *redis.StringSliceCmd { } } +func (rdbw * RDBWrapper) HMGet(key string, fields ...string) *redis.SliceCmd { + for { + if !rdbw.IsConnected() { + rdbw.WaitForConnection() + continue + } + + cmd := rdbw.Rdb.HMGet(key, fields...) + _, err := cmd.Result() + + if err != nil { + if !rdbw.CheckConnection(false) { + continue + } + } + + return cmd + } +} + // Wrapper for auto-logging and connection handling func (rdbw *RDBWrapper) HGetAll(key string) *redis.StringStringMapCmd { for {