mirror of
https://github.com/redis/go-redis.git
synced 2025-07-29 17:41:15 +03:00
committed by
GitHub
parent
08b4cc5f4b
commit
0d306237c7
17
commands.go
17
commands.go
@ -225,6 +225,7 @@ type Cmdable interface {
|
||||
LInsertBefore(ctx context.Context, key string, pivot, value interface{}) *IntCmd
|
||||
LInsertAfter(ctx context.Context, key string, pivot, value interface{}) *IntCmd
|
||||
LLen(ctx context.Context, key string) *IntCmd
|
||||
LMPop(ctx context.Context, direction string, count int64, keys ...string) *ListElementCmd
|
||||
LPop(ctx context.Context, key string) *StringCmd
|
||||
LPopCount(ctx context.Context, key string, count int) *StringSliceCmd
|
||||
LPos(ctx context.Context, key string, value string, args LPosArgs) *IntCmd
|
||||
@ -1463,6 +1464,22 @@ func (c cmdable) LIndex(ctx context.Context, key string, index int64) *StringCmd
|
||||
return cmd
|
||||
}
|
||||
|
||||
// LMPop Pops one or more elements from the first non-empty list key from the list of provided key names.
|
||||
// direction: left or right, count: > 0
|
||||
// example: client.LMPop(ctx, "left", 3, "key1", "key2")
|
||||
func (c cmdable) LMPop(ctx context.Context, direction string, count int64, keys ...string) *ListElementCmd {
|
||||
args := make([]interface{}, 2+len(keys), 5+len(keys))
|
||||
args[0] = "lmpop"
|
||||
args[1] = len(keys)
|
||||
for i, key := range keys {
|
||||
args[2+i] = key
|
||||
}
|
||||
args = append(args, strings.ToLower(direction), "count", count)
|
||||
cmd := NewListElementCmd(ctx, args...)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) LInsert(ctx context.Context, key, op string, pivot, value interface{}) *IntCmd {
|
||||
cmd := NewIntCmd(ctx, "linsert", key, op, pivot, value)
|
||||
_ = c(ctx, cmd)
|
||||
|
Reference in New Issue
Block a user