Redis: Add HKeys()

This commit is contained in:
Noah Hilverling 2019-03-06 16:29:18 +01:00
parent 972a717a32
commit 5a5ef2c3d8

View file

@ -67,6 +67,7 @@ type RedisClient interface {
Publish(channel string, message interface{}) *redis.IntCmd
XRead(a *redis.XReadArgs) *redis.XStreamSliceCmd
XDel(stream string, ids ...string) *redis.IntCmd
HKeys(key string) *redis.StringSliceCmd
HGetAll(key string) *redis.StringStringMapCmd
TxPipelined(fn func(redis.Pipeliner) error) ([]redis.Cmder, error)
Subscribe(channels ...string) *redis.PubSub
@ -220,6 +221,7 @@ func (rdbw *RDBWrapper) XRead(args *redis.XReadArgs) *redis.XStreamSliceCmd {
return cmd
}
}
// Wrapper for connection handling
func (rdbw *RDBWrapper) XDel(stream string, ids ...string) *redis.IntCmd {
for {
@ -241,6 +243,27 @@ func (rdbw *RDBWrapper) XDel(stream string, ids ...string) *redis.IntCmd {
}
}
// Wrapper for connection handling
func (rdbw *RDBWrapper) HKeys(key string) *redis.StringSliceCmd {
for {
if !rdbw.IsConnected() {
rdbw.WaitForConnection()
continue
}
cmd := rdbw.Rdb.HKeys(key)
_, 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) (map[string]string, error) {
for {