diff --git a/redis.go b/redis.go index 4f7ee6a8..4421c816 100644 --- a/redis.go +++ b/redis.go @@ -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 {