Redis: Add HMGet()

This commit is contained in:
Noah Hilverling 2019-03-15 15:58:41 +01:00
parent ddd64e7504
commit e6eb55207f

View file

@ -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 {