feat(redis): add zscan command implementation (#2729) (#2751)

This commit is contained in:
#Suyghur
2023-01-04 13:44:17 +08:00
committed by GitHub
parent 83f88d177f
commit 69d355eb4b
2 changed files with 52 additions and 0 deletions

View File

@@ -2017,6 +2017,28 @@ func (s *Redis) ZscoreCtx(ctx context.Context, key, value string) (val int64, er
return
}
// Zscan is the implementation of redis zscan command.
func (s *Redis) Zscan(key string, cursor uint64, match string, count int64) (
keys []string, cur uint64, err error) {
return s.ZscanCtx(context.Background(), key, cursor, match, count)
}
// ZscanCtx is the implementation of redis zscan command.
func (s *Redis) ZscanCtx(ctx context.Context, key string, cursor uint64, match string, count int64) (
keys []string, cur uint64, err error) {
err = s.brk.DoWithAcceptable(func() error {
conn, err := getRedis(s)
if err != nil {
return err
}
keys, cur, err = conn.ZScan(ctx, key, cursor, match, count).Result()
return err
}, acceptable)
return
}
// Zrank is the implementation of redis zrank command.
func (s *Redis) Zrank(key, field string) (int64, error) {
return s.ZrankCtx(context.Background(), key, field)