support zunionstore in redis (#410)

This commit is contained in:
Kevin Wan
2021-01-21 21:03:24 +08:00
committed by GitHub
parent ebec5aafab
commit a784982030
2 changed files with 30 additions and 1 deletions

View File

@@ -51,7 +51,8 @@ type (
Pipeliner = red.Pipeliner
// Z represents sorted set member.
Z = red.Z
Z = red.Z
ZStore = red.ZStore
IntCmd = red.IntCmd
FloatCmd = red.FloatCmd
@@ -1394,6 +1395,20 @@ func (s *Redis) Zrevrank(key string, field string) (val int64, err error) {
return
}
func (s *Redis) Zunionstore(dest string, store ZStore, keys ...string) (val int64, err error) {
err = s.brk.DoWithAcceptable(func() error {
conn, err := getRedis(s)
if err != nil {
return err
}
val, err = conn.ZUnionStore(dest, store, keys...).Result()
return err
}, acceptable)
return
}
func (s *Redis) String() string {
return s.Addr
}