mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
Adding support for ZMPOP command (#2408)
* feat: add ZMPOP command * fix: reply reading string * fix: evaluating a test tweak * fix: test fix * fix: reverting to debug * fix: test fix * fix: remove old implementation * feat: adding ZMPOP and tests * feat: modifying ZMpopCmd * fix: fix test * fix: test removal check * fix: fix testS * Adding more tests * fix: using redis.Nil instead of string * fix: renaming command to ZArrayWithKeyCmd to match the standard * feat: updated ZArrayWithKeyCmd to ZSliceWithKeyCmd * feat: adding help strings --------- Co-authored-by: Anuragkillswitch <70265851+Anuragkillswitch@users.noreply.github.com> Co-authored-by: Chayim <chayim@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
f95bdb8a8b
commit
621c02c583
17
commands.go
17
commands.go
@ -313,6 +313,7 @@ type Cmdable interface {
|
||||
ZInterWithScores(ctx context.Context, store *ZStore) *ZSliceCmd
|
||||
ZInterCard(ctx context.Context, limit int64, keys ...string) *IntCmd
|
||||
ZInterStore(ctx context.Context, destination string, store *ZStore) *IntCmd
|
||||
ZMPop(ctx context.Context, order string, count int64, keys ...string) *ZSliceWithKeyCmd
|
||||
ZMScore(ctx context.Context, key string, members ...string) *FloatSliceCmd
|
||||
ZPopMax(ctx context.Context, key string, count ...int64) *ZSliceCmd
|
||||
ZPopMin(ctx context.Context, key string, count ...int64) *ZSliceCmd
|
||||
@ -2473,6 +2474,22 @@ func (c cmdable) ZInterCard(ctx context.Context, limit int64, keys ...string) *I
|
||||
return cmd
|
||||
}
|
||||
|
||||
// ZMPop Pops one or more elements with the highest or lowest score from the first non-empty sorted set key from the list of provided key names.
|
||||
// direction: "max" (highest score) or "min" (lowest score), count: > 0
|
||||
// example: client.ZMPop(ctx, "max", 5, "set1", "set2")
|
||||
func (c cmdable) ZMPop(ctx context.Context, order string, count int64, keys ...string) *ZSliceWithKeyCmd {
|
||||
args := make([]interface{}, 2+len(keys), 5+len(keys))
|
||||
args[0] = "zmpop"
|
||||
args[1] = len(keys)
|
||||
for i, key := range keys {
|
||||
args[2+i] = key
|
||||
}
|
||||
args = append(args, strings.ToLower(order), "count", count)
|
||||
cmd := NewZSliceWithKeyCmd(ctx, args...)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) ZMScore(ctx context.Context, key string, members ...string) *FloatSliceCmd {
|
||||
args := make([]interface{}, 2+len(members))
|
||||
args[0] = "zmscore"
|
||||
|
Reference in New Issue
Block a user