1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

Making LpushX and RpushX variadic

This commit is contained in:
sjindal995
2019-07-18 16:48:09 +05:30
parent 94359d94c1
commit 5c3de7537a
2 changed files with 40 additions and 6 deletions

View File

@ -140,7 +140,7 @@ type Cmdable interface {
LLen(key string) *IntCmd
LPop(key string) *StringCmd
LPush(key string, values ...interface{}) *IntCmd
LPushX(key string, value interface{}) *IntCmd
LPushX(key string, value interface{}, values ...interface{}) *IntCmd
LRange(key string, start, stop int64) *StringSliceCmd
LRem(key string, count int64, value interface{}) *IntCmd
LSet(key string, index int64, value interface{}) *StatusCmd
@ -148,7 +148,7 @@ type Cmdable interface {
RPop(key string) *StringCmd
RPopLPush(source, destination string) *StringCmd
RPush(key string, values ...interface{}) *IntCmd
RPushX(key string, value interface{}) *IntCmd
RPushX(key string, value interface{}, values ...interface{}) *IntCmd
SAdd(key string, members ...interface{}) *IntCmd
SCard(key string) *IntCmd
SDiff(keys ...string) *StringSliceCmd
@ -1087,8 +1087,13 @@ func (c cmdable) LPush(key string, values ...interface{}) *IntCmd {
return cmd
}
func (c cmdable) LPushX(key string, value interface{}) *IntCmd {
cmd := NewIntCmd("lpushx", key, value)
func (c cmdable) LPushX(key string, value interface{}, values ...interface{}) *IntCmd {
args := make([]interface{}, 3, 3+len(values))
args[0] = "lpushx"
args[1] = key
args[2] = value
args = appendArgs(args, values)
cmd := NewIntCmd(args...)
c(cmd)
return cmd
}
@ -1149,8 +1154,13 @@ func (c cmdable) RPush(key string, values ...interface{}) *IntCmd {
return cmd
}
func (c cmdable) RPushX(key string, value interface{}) *IntCmd {
cmd := NewIntCmd("rpushx", key, value)
func (c cmdable) RPushX(key string, value interface{}, values ...interface{}) *IntCmd {
args := make([]interface{}, 3, 3+len(values))
args[0] = "rpushx"
args[1] = key
args[2] = value
args = appendArgs(args, values)
cmd := NewIntCmd(args...)
c(cmd)
return cmd
}