Update Vendor (#16325)
* Add Dependencie Update Script * update gitea.com/lunny/levelqueue * update github.com/PuerkitoBio/goquery * update github.com/alecthomas/chroma * update github.com/blevesearch/bleve/v2 * update github.com/caddyserver/certmagic * update github.com/go-enry/go-enry/v2 * update github.com/go-redis/redis/v8 * update github.com/hashicorp/golang-lru * update github.com/klauspost/compress * update github.com/markbates/goth * update github.com/mholt/archiver/v3 * update github.com/microcosm-cc/bluemonday * update github.com/minio/minio-go/v7 * update github.com/olivere/elastic/v7 * update github.com/xanzy/go-gitlab * update github.com/yuin/goldmark
This commit is contained in:
parent
65ae46bc20
commit
fae07cbc8f
319 changed files with 33568 additions and 21050 deletions
638
vendor/github.com/go-redis/redis/v8/commands.go
generated
vendored
638
vendor/github.com/go-redis/redis/v8/commands.go
generated
vendored
|
@ -9,7 +9,8 @@ import (
|
|||
"github.com/go-redis/redis/v8/internal"
|
||||
)
|
||||
|
||||
// KeepTTL is an option for Set command to keep key's existing TTL.
|
||||
// KeepTTL is a Redis KEEPTTL option to keep existing TTL, it requires your redis-server version >= 6.0,
|
||||
// otherwise you will receive an error: (error) ERR syntax error.
|
||||
// For example:
|
||||
//
|
||||
// rdb.Set(ctx, key, value, redis.KeepTTL)
|
||||
|
@ -226,6 +227,7 @@ type Cmdable interface {
|
|||
XGroupCreateMkStream(ctx context.Context, stream, group, start string) *StatusCmd
|
||||
XGroupSetID(ctx context.Context, stream, group, start string) *StatusCmd
|
||||
XGroupDestroy(ctx context.Context, stream, group string) *IntCmd
|
||||
XGroupCreateConsumer(ctx context.Context, stream, group, consumer string) *IntCmd
|
||||
XGroupDelConsumer(ctx context.Context, stream, group, consumer string) *IntCmd
|
||||
XReadGroup(ctx context.Context, a *XReadGroupArgs) *XStreamSliceCmd
|
||||
XAck(ctx context.Context, stream, group string, ids ...string) *IntCmd
|
||||
|
@ -233,20 +235,39 @@ type Cmdable interface {
|
|||
XPendingExt(ctx context.Context, a *XPendingExtArgs) *XPendingExtCmd
|
||||
XClaim(ctx context.Context, a *XClaimArgs) *XMessageSliceCmd
|
||||
XClaimJustID(ctx context.Context, a *XClaimArgs) *StringSliceCmd
|
||||
|
||||
// TODO: XTrim and XTrimApprox remove in v9.
|
||||
XTrim(ctx context.Context, key string, maxLen int64) *IntCmd
|
||||
XTrimApprox(ctx context.Context, key string, maxLen int64) *IntCmd
|
||||
XTrimMaxLen(ctx context.Context, key string, maxLen int64) *IntCmd
|
||||
XTrimMaxLenApprox(ctx context.Context, key string, maxLen, limit int64) *IntCmd
|
||||
XTrimMinID(ctx context.Context, key string, minID string) *IntCmd
|
||||
XTrimMinIDApprox(ctx context.Context, key string, minID string, limit int64) *IntCmd
|
||||
XInfoGroups(ctx context.Context, key string) *XInfoGroupsCmd
|
||||
XInfoStream(ctx context.Context, key string) *XInfoStreamCmd
|
||||
XInfoConsumers(ctx context.Context, key string, group string) *XInfoConsumersCmd
|
||||
|
||||
BZPopMax(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd
|
||||
BZPopMin(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd
|
||||
|
||||
// TODO: remove
|
||||
// ZAddCh
|
||||
// ZIncr
|
||||
// ZAddNXCh
|
||||
// ZAddXXCh
|
||||
// ZIncrNX
|
||||
// ZIncrXX
|
||||
// in v9.
|
||||
// use ZAddArgs and ZAddArgsIncr.
|
||||
|
||||
ZAdd(ctx context.Context, key string, members ...*Z) *IntCmd
|
||||
ZAddNX(ctx context.Context, key string, members ...*Z) *IntCmd
|
||||
ZAddXX(ctx context.Context, key string, members ...*Z) *IntCmd
|
||||
ZAddCh(ctx context.Context, key string, members ...*Z) *IntCmd
|
||||
ZAddNXCh(ctx context.Context, key string, members ...*Z) *IntCmd
|
||||
ZAddXXCh(ctx context.Context, key string, members ...*Z) *IntCmd
|
||||
ZAddArgs(ctx context.Context, key string, args ZAddArgs) *IntCmd
|
||||
ZAddArgsIncr(ctx context.Context, key string, args ZAddArgs) *FloatCmd
|
||||
ZIncr(ctx context.Context, key string, member *Z) *FloatCmd
|
||||
ZIncrNX(ctx context.Context, key string, member *Z) *FloatCmd
|
||||
ZIncrXX(ctx context.Context, key string, member *Z) *FloatCmd
|
||||
|
@ -265,6 +286,9 @@ type Cmdable interface {
|
|||
ZRangeByScore(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd
|
||||
ZRangeByLex(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd
|
||||
ZRangeByScoreWithScores(ctx context.Context, key string, opt *ZRangeBy) *ZSliceCmd
|
||||
ZRangeArgs(ctx context.Context, z ZRangeArgs) *StringSliceCmd
|
||||
ZRangeArgsWithScores(ctx context.Context, z ZRangeArgs) *ZSliceCmd
|
||||
ZRangeStore(ctx context.Context, dst string, z ZRangeArgs) *IntCmd
|
||||
ZRank(ctx context.Context, key, member string) *IntCmd
|
||||
ZRem(ctx context.Context, key string, members ...interface{}) *IntCmd
|
||||
ZRemRangeByRank(ctx context.Context, key string, start, stop int64) *IntCmd
|
||||
|
@ -278,6 +302,8 @@ type Cmdable interface {
|
|||
ZRevRank(ctx context.Context, key, member string) *IntCmd
|
||||
ZScore(ctx context.Context, key, member string) *FloatCmd
|
||||
ZUnionStore(ctx context.Context, dest string, store *ZStore) *IntCmd
|
||||
ZUnion(ctx context.Context, store ZStore) *StringSliceCmd
|
||||
ZUnionWithScores(ctx context.Context, store ZStore) *ZSliceCmd
|
||||
ZRandMember(ctx context.Context, key string, count int, withScores bool) *StringSliceCmd
|
||||
ZDiff(ctx context.Context, keys ...string) *StringSliceCmd
|
||||
ZDiffWithScores(ctx context.Context, keys ...string) *ZSliceCmd
|
||||
|
@ -386,7 +412,7 @@ func (c statefulCmdable) Auth(ctx context.Context, password string) *StatusCmd {
|
|||
return cmd
|
||||
}
|
||||
|
||||
// Perform an AUTH command, using the given user and pass.
|
||||
// AuthACL Perform an AUTH command, using the given user and pass.
|
||||
// Should be used to authenticate the current connection with one of the connections defined in the ACL list
|
||||
// when connecting to a Redis 6.0 instance, or greater, that is using the Redis ACL system.
|
||||
func (c statefulCmdable) AuthACL(ctx context.Context, username, password string) *StatusCmd {
|
||||
|
@ -447,7 +473,7 @@ func (c cmdable) Ping(ctx context.Context) *StatusCmd {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) Quit(ctx context.Context) *StatusCmd {
|
||||
func (c cmdable) Quit(_ context.Context) *StatusCmd {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
|
@ -710,7 +736,7 @@ func (c cmdable) DecrBy(ctx context.Context, key string, decrement int64) *IntCm
|
|||
return cmd
|
||||
}
|
||||
|
||||
// Redis `GET key` command. It returns redis.Nil error when key does not exist.
|
||||
// Get Redis `GET key` command. It returns redis.Nil error when key does not exist.
|
||||
func (c cmdable) Get(ctx context.Context, key string) *StringCmd {
|
||||
cmd := NewStringCmd(ctx, "get", key)
|
||||
_ = c(ctx, cmd)
|
||||
|
@ -729,7 +755,7 @@ func (c cmdable) GetSet(ctx context.Context, key string, value interface{}) *Str
|
|||
return cmd
|
||||
}
|
||||
|
||||
// An expiration of zero removes the TTL associated with the key (i.e. GETEX key persist).
|
||||
// GetEx An expiration of zero removes the TTL associated with the key (i.e. GETEX key persist).
|
||||
// Requires Redis >= 6.2.0.
|
||||
func (c cmdable) GetEx(ctx context.Context, key string, expiration time.Duration) *StringCmd {
|
||||
args := make([]interface{}, 0, 4)
|
||||
|
@ -749,7 +775,7 @@ func (c cmdable) GetEx(ctx context.Context, key string, expiration time.Duration
|
|||
return cmd
|
||||
}
|
||||
|
||||
// redis-server version >= 6.2.0.
|
||||
// GetDel redis-server version >= 6.2.0.
|
||||
func (c cmdable) GetDel(ctx context.Context, key string) *StringCmd {
|
||||
cmd := NewStringCmd(ctx, "getdel", key)
|
||||
_ = c(ctx, cmd)
|
||||
|
@ -811,11 +837,12 @@ func (c cmdable) MSetNX(ctx context.Context, values ...interface{}) *BoolCmd {
|
|||
return cmd
|
||||
}
|
||||
|
||||
// Redis `SET key value [expiration]` command.
|
||||
// Set Redis `SET key value [expiration]` command.
|
||||
// Use expiration for `SETEX`-like behavior.
|
||||
//
|
||||
// Zero expiration means the key has no expiration time.
|
||||
// KeepTTL(-1) expiration is a Redis KEEPTTL option to keep existing TTL.
|
||||
// KeepTTL is a Redis KEEPTTL option to keep existing TTL, it requires your redis-server version >= 6.0,
|
||||
// otherwise you will receive an error: (error) ERR syntax error.
|
||||
func (c cmdable) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd {
|
||||
args := make([]interface{}, 3, 5)
|
||||
args[0] = "set"
|
||||
|
@ -848,7 +875,8 @@ type SetArgs struct {
|
|||
// When Get is true, the command returns the old value stored at key, or nil when key did not exist.
|
||||
Get bool
|
||||
|
||||
// KeepTTL is a Redis KEEPTTL option to keep existing TTL.
|
||||
// KeepTTL is a Redis KEEPTTL option to keep existing TTL, it requires your redis-server version >= 6.0,
|
||||
// otherwise you will receive an error: (error) ERR syntax error.
|
||||
KeepTTL bool
|
||||
}
|
||||
|
||||
|
@ -886,17 +914,18 @@ func (c cmdable) SetArgs(ctx context.Context, key string, value interface{}, a S
|
|||
return cmd
|
||||
}
|
||||
|
||||
// Redis `SETEX key expiration value` command.
|
||||
// SetEX Redis `SETEX key expiration value` command.
|
||||
func (c cmdable) SetEX(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd {
|
||||
cmd := NewStatusCmd(ctx, "setex", key, formatSec(ctx, expiration), value)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// Redis `SET key value [expiration] NX` command.
|
||||
// SetNX Redis `SET key value [expiration] NX` command.
|
||||
//
|
||||
// Zero expiration means the key has no expiration time.
|
||||
// KeepTTL(-1) expiration is a Redis KEEPTTL option to keep existing TTL.
|
||||
// KeepTTL is a Redis KEEPTTL option to keep existing TTL, it requires your redis-server version >= 6.0,
|
||||
// otherwise you will receive an error: (error) ERR syntax error.
|
||||
func (c cmdable) SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd {
|
||||
var cmd *BoolCmd
|
||||
switch expiration {
|
||||
|
@ -917,10 +946,11 @@ func (c cmdable) SetNX(ctx context.Context, key string, value interface{}, expir
|
|||
return cmd
|
||||
}
|
||||
|
||||
// Redis `SET key value [expiration] XX` command.
|
||||
// SetXX Redis `SET key value [expiration] XX` command.
|
||||
//
|
||||
// Zero expiration means the key has no expiration time.
|
||||
// KeepTTL(-1) expiration is a Redis KEEPTTL option to keep existing TTL.
|
||||
// KeepTTL is a Redis KEEPTTL option to keep existing TTL, it requires your redis-server version >= 6.0,
|
||||
// otherwise you will receive an error: (error) ERR syntax error.
|
||||
func (c cmdable) SetXX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd {
|
||||
var cmd *BoolCmd
|
||||
switch expiration {
|
||||
|
@ -1228,7 +1258,7 @@ func (c cmdable) HVals(ctx context.Context, key string) *StringSliceCmd {
|
|||
return cmd
|
||||
}
|
||||
|
||||
// redis-server version >= 6.2.0.
|
||||
// HRandField redis-server version >= 6.2.0.
|
||||
func (c cmdable) HRandField(ctx context.Context, key string, count int, withValues bool) *StringSliceCmd {
|
||||
args := make([]interface{}, 0, 4)
|
||||
|
||||
|
@ -1521,7 +1551,7 @@ func (c cmdable) SIsMember(ctx context.Context, key string, member interface{})
|
|||
return cmd
|
||||
}
|
||||
|
||||
// Redis `SMISMEMBER key member [member ...]` command.
|
||||
// SMIsMember Redis `SMISMEMBER key member [member ...]` command.
|
||||
func (c cmdable) SMIsMember(ctx context.Context, key string, members ...interface{}) *BoolSliceCmd {
|
||||
args := make([]interface{}, 2, 2+len(members))
|
||||
args[0] = "smismember"
|
||||
|
@ -1532,14 +1562,14 @@ func (c cmdable) SMIsMember(ctx context.Context, key string, members ...interfac
|
|||
return cmd
|
||||
}
|
||||
|
||||
// Redis `SMEMBERS key` command output as a slice.
|
||||
// SMembers Redis `SMEMBERS key` command output as a slice.
|
||||
func (c cmdable) SMembers(ctx context.Context, key string) *StringSliceCmd {
|
||||
cmd := NewStringSliceCmd(ctx, "smembers", key)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// Redis `SMEMBERS key` command output as a map.
|
||||
// SMembersMap Redis `SMEMBERS key` command output as a map.
|
||||
func (c cmdable) SMembersMap(ctx context.Context, key string) *StringStructMapCmd {
|
||||
cmd := NewStringStructMapCmd(ctx, "smembers", key)
|
||||
_ = c(ctx, cmd)
|
||||
|
@ -1552,28 +1582,28 @@ func (c cmdable) SMove(ctx context.Context, source, destination string, member i
|
|||
return cmd
|
||||
}
|
||||
|
||||
// Redis `SPOP key` command.
|
||||
// SPop Redis `SPOP key` command.
|
||||
func (c cmdable) SPop(ctx context.Context, key string) *StringCmd {
|
||||
cmd := NewStringCmd(ctx, "spop", key)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// Redis `SPOP key count` command.
|
||||
// SPopN Redis `SPOP key count` command.
|
||||
func (c cmdable) SPopN(ctx context.Context, key string, count int64) *StringSliceCmd {
|
||||
cmd := NewStringSliceCmd(ctx, "spop", key, count)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// Redis `SRANDMEMBER key` command.
|
||||
// SRandMember Redis `SRANDMEMBER key` command.
|
||||
func (c cmdable) SRandMember(ctx context.Context, key string) *StringCmd {
|
||||
cmd := NewStringCmd(ctx, "srandmember", key)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// Redis `SRANDMEMBER key count` command.
|
||||
// SRandMemberN Redis `SRANDMEMBER key count` command.
|
||||
func (c cmdable) SRandMemberN(ctx context.Context, key string, count int64) *StringSliceCmd {
|
||||
cmd := NewStringSliceCmd(ctx, "srandmember", key, count)
|
||||
_ = c(ctx, cmd)
|
||||
|
@ -1621,22 +1651,50 @@ func (c cmdable) SUnionStore(ctx context.Context, destination string, keys ...st
|
|||
// - XAddArgs.Values = map[string]interface{}{"key1": "value1", "key2": "value2"}
|
||||
//
|
||||
// Note that map will not preserve the order of key-value pairs.
|
||||
// MaxLen/MaxLenApprox and MinID are in conflict, only one of them can be used.
|
||||
type XAddArgs struct {
|
||||
Stream string
|
||||
MaxLen int64 // MAXLEN N
|
||||
Stream string
|
||||
NoMkStream bool
|
||||
MaxLen int64 // MAXLEN N
|
||||
|
||||
// Deprecated: use MaxLen+Approx, remove in v9.
|
||||
MaxLenApprox int64 // MAXLEN ~ N
|
||||
ID string
|
||||
Values interface{}
|
||||
|
||||
MinID string
|
||||
// Approx causes MaxLen and MinID to use "~" matcher (instead of "=").
|
||||
Approx bool
|
||||
Limit int64
|
||||
ID string
|
||||
Values interface{}
|
||||
}
|
||||
|
||||
// XAdd a.Limit has a bug, please confirm it and use it.
|
||||
// issue: https://github.com/redis/redis/issues/9046
|
||||
func (c cmdable) XAdd(ctx context.Context, a *XAddArgs) *StringCmd {
|
||||
args := make([]interface{}, 0, 8)
|
||||
args = append(args, "xadd")
|
||||
args = append(args, a.Stream)
|
||||
if a.MaxLen > 0 {
|
||||
args = append(args, "maxlen", a.MaxLen)
|
||||
} else if a.MaxLenApprox > 0 {
|
||||
args := make([]interface{}, 0, 11)
|
||||
args = append(args, "xadd", a.Stream)
|
||||
if a.NoMkStream {
|
||||
args = append(args, "nomkstream")
|
||||
}
|
||||
switch {
|
||||
case a.MaxLen > 0:
|
||||
if a.Approx {
|
||||
args = append(args, "maxlen", "~", a.MaxLen)
|
||||
} else {
|
||||
args = append(args, "maxlen", a.MaxLen)
|
||||
}
|
||||
case a.MaxLenApprox > 0:
|
||||
// TODO remove in v9.
|
||||
args = append(args, "maxlen", "~", a.MaxLenApprox)
|
||||
case a.MinID != "":
|
||||
if a.Approx {
|
||||
args = append(args, "minid", "~", a.MinID)
|
||||
} else {
|
||||
args = append(args, "minid", a.MinID)
|
||||
}
|
||||
}
|
||||
if a.Limit > 0 {
|
||||
args = append(args, "limit", a.Limit)
|
||||
}
|
||||
if a.ID != "" {
|
||||
args = append(args, a.ID)
|
||||
|
@ -1757,6 +1815,12 @@ func (c cmdable) XGroupDestroy(ctx context.Context, stream, group string) *IntCm
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) XGroupCreateConsumer(ctx context.Context, stream, group, consumer string) *IntCmd {
|
||||
cmd := NewIntCmd(ctx, "xgroup", "createconsumer", stream, group, consumer)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) XGroupDelConsumer(ctx context.Context, stream, group, consumer string) *IntCmd {
|
||||
cmd := NewIntCmd(ctx, "xgroup", "delconsumer", stream, group, consumer)
|
||||
_ = c(ctx, cmd)
|
||||
|
@ -1845,6 +1909,39 @@ func (c cmdable) XPendingExt(ctx context.Context, a *XPendingExtArgs) *XPendingE
|
|||
return cmd
|
||||
}
|
||||
|
||||
type XAutoClaimArgs struct {
|
||||
Stream string
|
||||
Group string
|
||||
MinIdle time.Duration
|
||||
Start string
|
||||
Count int64
|
||||
Consumer string
|
||||
}
|
||||
|
||||
func (c cmdable) XAutoClaim(ctx context.Context, a *XAutoClaimArgs) *XAutoClaimCmd {
|
||||
args := xAutoClaimArgs(ctx, a)
|
||||
cmd := NewXAutoClaimCmd(ctx, args...)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) XAutoClaimJustID(ctx context.Context, a *XAutoClaimArgs) *XAutoClaimJustIDCmd {
|
||||
args := xAutoClaimArgs(ctx, a)
|
||||
args = append(args, "justid")
|
||||
cmd := NewXAutoClaimJustIDCmd(ctx, args...)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func xAutoClaimArgs(ctx context.Context, a *XAutoClaimArgs) []interface{} {
|
||||
args := make([]interface{}, 0, 9)
|
||||
args = append(args, "xautoclaim", a.Stream, a.Group, a.Consumer, formatMs(ctx, a.MinIdle), a.Start)
|
||||
if a.Count > 0 {
|
||||
args = append(args, "count", a.Count)
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
type XClaimArgs struct {
|
||||
Stream string
|
||||
Group string
|
||||
|
@ -1881,16 +1978,63 @@ func xClaimArgs(a *XClaimArgs) []interface{} {
|
|||
return args
|
||||
}
|
||||
|
||||
func (c cmdable) XTrim(ctx context.Context, key string, maxLen int64) *IntCmd {
|
||||
cmd := NewIntCmd(ctx, "xtrim", key, "maxlen", maxLen)
|
||||
// xTrim If approx is true, add the "~" parameter, otherwise it is the default "=" (redis default).
|
||||
// example:
|
||||
// XTRIM key MAXLEN/MINID threshold LIMIT limit.
|
||||
// XTRIM key MAXLEN/MINID ~ threshold LIMIT limit.
|
||||
// The redis-server version is lower than 6.2, please set limit to 0.
|
||||
func (c cmdable) xTrim(
|
||||
ctx context.Context, key, strategy string,
|
||||
approx bool, threshold interface{}, limit int64,
|
||||
) *IntCmd {
|
||||
args := make([]interface{}, 0, 7)
|
||||
args = append(args, "xtrim", key, strategy)
|
||||
if approx {
|
||||
args = append(args, "~")
|
||||
}
|
||||
args = append(args, threshold)
|
||||
if limit > 0 {
|
||||
args = append(args, "limit", limit)
|
||||
}
|
||||
cmd := NewIntCmd(ctx, args...)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// Deprecated: use XTrimMaxLen, remove in v9.
|
||||
func (c cmdable) XTrim(ctx context.Context, key string, maxLen int64) *IntCmd {
|
||||
return c.xTrim(ctx, key, "maxlen", false, maxLen, 0)
|
||||
}
|
||||
|
||||
// Deprecated: use XTrimMaxLenApprox, remove in v9.
|
||||
func (c cmdable) XTrimApprox(ctx context.Context, key string, maxLen int64) *IntCmd {
|
||||
cmd := NewIntCmd(ctx, "xtrim", key, "maxlen", "~", maxLen)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
return c.xTrim(ctx, key, "maxlen", true, maxLen, 0)
|
||||
}
|
||||
|
||||
// XTrimMaxLen No `~` rules are used, `limit` cannot be used.
|
||||
// cmd: XTRIM key MAXLEN maxLen
|
||||
func (c cmdable) XTrimMaxLen(ctx context.Context, key string, maxLen int64) *IntCmd {
|
||||
return c.xTrim(ctx, key, "maxlen", false, maxLen, 0)
|
||||
}
|
||||
|
||||
// XTrimMaxLenApprox LIMIT has a bug, please confirm it and use it.
|
||||
// issue: https://github.com/redis/redis/issues/9046
|
||||
// cmd: XTRIM key MAXLEN ~ maxLen LIMIT limit
|
||||
func (c cmdable) XTrimMaxLenApprox(ctx context.Context, key string, maxLen, limit int64) *IntCmd {
|
||||
return c.xTrim(ctx, key, "maxlen", true, maxLen, limit)
|
||||
}
|
||||
|
||||
// XTrimMinID No `~` rules are used, `limit` cannot be used.
|
||||
// cmd: XTRIM key MINID minID
|
||||
func (c cmdable) XTrimMinID(ctx context.Context, key string, minID string) *IntCmd {
|
||||
return c.xTrim(ctx, key, "minid", false, minID, 0)
|
||||
}
|
||||
|
||||
// XTrimMinIDApprox LIMIT has a bug, please confirm it and use it.
|
||||
// issue: https://github.com/redis/redis/issues/9046
|
||||
// cmd: XTRIM key MINID ~ minID LIMIT limit
|
||||
func (c cmdable) XTrimMinIDApprox(ctx context.Context, key string, minID string, limit int64) *IntCmd {
|
||||
return c.xTrim(ctx, key, "minid", true, minID, limit)
|
||||
}
|
||||
|
||||
func (c cmdable) XInfoConsumers(ctx context.Context, key string, group string) *XInfoConsumersCmd {
|
||||
|
@ -1938,7 +2082,7 @@ type ZWithKey struct {
|
|||
Key string
|
||||
}
|
||||
|
||||
// ZStore is used as an arg to ZInterStore and ZUnionStore.
|
||||
// ZStore is used as an arg to ZInter/ZInterStore and ZUnion/ZUnionStore.
|
||||
type ZStore struct {
|
||||
Keys []string
|
||||
Weights []float64
|
||||
|
@ -1946,7 +2090,7 @@ type ZStore struct {
|
|||
Aggregate string
|
||||
}
|
||||
|
||||
func (z *ZStore) len() (n int) {
|
||||
func (z ZStore) len() (n int) {
|
||||
n = len(z.Keys)
|
||||
if len(z.Weights) > 0 {
|
||||
n += 1 + len(z.Weights)
|
||||
|
@ -1957,7 +2101,23 @@ func (z *ZStore) len() (n int) {
|
|||
return n
|
||||
}
|
||||
|
||||
// Redis `BZPOPMAX key [key ...] timeout` command.
|
||||
func (z ZStore) appendArgs(args []interface{}) []interface{} {
|
||||
for _, key := range z.Keys {
|
||||
args = append(args, key)
|
||||
}
|
||||
if len(z.Weights) > 0 {
|
||||
args = append(args, "weights")
|
||||
for _, weights := range z.Weights {
|
||||
args = append(args, weights)
|
||||
}
|
||||
}
|
||||
if z.Aggregate != "" {
|
||||
args = append(args, "aggregate", z.Aggregate)
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
// BZPopMax Redis `BZPOPMAX key [key ...] timeout` command.
|
||||
func (c cmdable) BZPopMax(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd {
|
||||
args := make([]interface{}, 1+len(keys)+1)
|
||||
args[0] = "bzpopmax"
|
||||
|
@ -1971,7 +2131,7 @@ func (c cmdable) BZPopMax(ctx context.Context, timeout time.Duration, keys ...st
|
|||
return cmd
|
||||
}
|
||||
|
||||
// Redis `BZPOPMIN key [key ...] timeout` command.
|
||||
// BZPopMin Redis `BZPOPMIN key [key ...] timeout` command.
|
||||
func (c cmdable) BZPopMin(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd {
|
||||
args := make([]interface{}, 1+len(keys)+1)
|
||||
args[0] = "bzpopmin"
|
||||
|
@ -1985,96 +2145,169 @@ func (c cmdable) BZPopMin(ctx context.Context, timeout time.Duration, keys ...st
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) zAdd(ctx context.Context, a []interface{}, n int, members ...*Z) *IntCmd {
|
||||
for i, m := range members {
|
||||
a[n+2*i] = m.Score
|
||||
a[n+2*i+1] = m.Member
|
||||
// ZAddArgs WARN: The GT, LT and NX options are mutually exclusive.
|
||||
type ZAddArgs struct {
|
||||
NX bool
|
||||
XX bool
|
||||
LT bool
|
||||
GT bool
|
||||
Ch bool
|
||||
Members []Z
|
||||
}
|
||||
|
||||
func (c cmdable) zAddArgs(key string, args ZAddArgs, incr bool) []interface{} {
|
||||
a := make([]interface{}, 0, 6+2*len(args.Members))
|
||||
a = append(a, "zadd", key)
|
||||
|
||||
// The GT, LT and NX options are mutually exclusive.
|
||||
if args.NX {
|
||||
a = append(a, "nx")
|
||||
} else {
|
||||
if args.XX {
|
||||
a = append(a, "xx")
|
||||
}
|
||||
if args.GT {
|
||||
a = append(a, "gt")
|
||||
} else if args.LT {
|
||||
a = append(a, "lt")
|
||||
}
|
||||
}
|
||||
cmd := NewIntCmd(ctx, a...)
|
||||
if args.Ch {
|
||||
a = append(a, "ch")
|
||||
}
|
||||
if incr {
|
||||
a = append(a, "incr")
|
||||
}
|
||||
for _, m := range args.Members {
|
||||
a = append(a, m.Score)
|
||||
a = append(a, m.Member)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func (c cmdable) ZAddArgs(ctx context.Context, key string, args ZAddArgs) *IntCmd {
|
||||
cmd := NewIntCmd(ctx, c.zAddArgs(key, args, false)...)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// Redis `ZADD key score member [score member ...]` command.
|
||||
func (c cmdable) ZAddArgsIncr(ctx context.Context, key string, args ZAddArgs) *FloatCmd {
|
||||
cmd := NewFloatCmd(ctx, c.zAddArgs(key, args, true)...)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// TODO: Compatible with v8 api, will be removed in v9.
|
||||
func (c cmdable) zAdd(ctx context.Context, key string, args ZAddArgs, members ...*Z) *IntCmd {
|
||||
args.Members = make([]Z, len(members))
|
||||
for i, m := range members {
|
||||
args.Members[i] = *m
|
||||
}
|
||||
cmd := NewIntCmd(ctx, c.zAddArgs(key, args, false)...)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// ZAdd Redis `ZADD key score member [score member ...]` command.
|
||||
func (c cmdable) ZAdd(ctx context.Context, key string, members ...*Z) *IntCmd {
|
||||
const n = 2
|
||||
a := make([]interface{}, n+2*len(members))
|
||||
a[0], a[1] = "zadd", key
|
||||
return c.zAdd(ctx, a, n, members...)
|
||||
return c.zAdd(ctx, key, ZAddArgs{}, members...)
|
||||
}
|
||||
|
||||
// Redis `ZADD key NX score member [score member ...]` command.
|
||||
// ZAddNX Redis `ZADD key NX score member [score member ...]` command.
|
||||
func (c cmdable) ZAddNX(ctx context.Context, key string, members ...*Z) *IntCmd {
|
||||
const n = 3
|
||||
a := make([]interface{}, n+2*len(members))
|
||||
a[0], a[1], a[2] = "zadd", key, "nx"
|
||||
return c.zAdd(ctx, a, n, members...)
|
||||
return c.zAdd(ctx, key, ZAddArgs{
|
||||
NX: true,
|
||||
}, members...)
|
||||
}
|
||||
|
||||
// Redis `ZADD key XX score member [score member ...]` command.
|
||||
// ZAddXX Redis `ZADD key XX score member [score member ...]` command.
|
||||
func (c cmdable) ZAddXX(ctx context.Context, key string, members ...*Z) *IntCmd {
|
||||
const n = 3
|
||||
a := make([]interface{}, n+2*len(members))
|
||||
a[0], a[1], a[2] = "zadd", key, "xx"
|
||||
return c.zAdd(ctx, a, n, members...)
|
||||
return c.zAdd(ctx, key, ZAddArgs{
|
||||
XX: true,
|
||||
}, members...)
|
||||
}
|
||||
|
||||
// Redis `ZADD key CH score member [score member ...]` command.
|
||||
// ZAddCh Redis `ZADD key CH score member [score member ...]` command.
|
||||
// Deprecated: Use
|
||||
// client.ZAddArgs(ctx, ZAddArgs{
|
||||
// Ch: true,
|
||||
// Members: []Z,
|
||||
// })
|
||||
// remove in v9.
|
||||
func (c cmdable) ZAddCh(ctx context.Context, key string, members ...*Z) *IntCmd {
|
||||
const n = 3
|
||||
a := make([]interface{}, n+2*len(members))
|
||||
a[0], a[1], a[2] = "zadd", key, "ch"
|
||||
return c.zAdd(ctx, a, n, members...)
|
||||
return c.zAdd(ctx, key, ZAddArgs{
|
||||
Ch: true,
|
||||
}, members...)
|
||||
}
|
||||
|
||||
// Redis `ZADD key NX CH score member [score member ...]` command.
|
||||
// ZAddNXCh Redis `ZADD key NX CH score member [score member ...]` command.
|
||||
// Deprecated: Use
|
||||
// client.ZAddArgs(ctx, ZAddArgs{
|
||||
// NX: true,
|
||||
// Ch: true,
|
||||
// Members: []Z,
|
||||
// })
|
||||
// remove in v9.
|
||||
func (c cmdable) ZAddNXCh(ctx context.Context, key string, members ...*Z) *IntCmd {
|
||||
const n = 4
|
||||
a := make([]interface{}, n+2*len(members))
|
||||
a[0], a[1], a[2], a[3] = "zadd", key, "nx", "ch"
|
||||
return c.zAdd(ctx, a, n, members...)
|
||||
return c.zAdd(ctx, key, ZAddArgs{
|
||||
NX: true,
|
||||
Ch: true,
|
||||
}, members...)
|
||||
}
|
||||
|
||||
// Redis `ZADD key XX CH score member [score member ...]` command.
|
||||
// ZAddXXCh Redis `ZADD key XX CH score member [score member ...]` command.
|
||||
// Deprecated: Use
|
||||
// client.ZAddArgs(ctx, ZAddArgs{
|
||||
// XX: true,
|
||||
// Ch: true,
|
||||
// Members: []Z,
|
||||
// })
|
||||
// remove in v9.
|
||||
func (c cmdable) ZAddXXCh(ctx context.Context, key string, members ...*Z) *IntCmd {
|
||||
const n = 4
|
||||
a := make([]interface{}, n+2*len(members))
|
||||
a[0], a[1], a[2], a[3] = "zadd", key, "xx", "ch"
|
||||
return c.zAdd(ctx, a, n, members...)
|
||||
return c.zAdd(ctx, key, ZAddArgs{
|
||||
XX: true,
|
||||
Ch: true,
|
||||
}, members...)
|
||||
}
|
||||
|
||||
func (c cmdable) zIncr(ctx context.Context, a []interface{}, n int, members ...*Z) *FloatCmd {
|
||||
for i, m := range members {
|
||||
a[n+2*i] = m.Score
|
||||
a[n+2*i+1] = m.Member
|
||||
}
|
||||
cmd := NewFloatCmd(ctx, a...)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// Redis `ZADD key INCR score member` command.
|
||||
// ZIncr Redis `ZADD key INCR score member` command.
|
||||
// Deprecated: Use
|
||||
// client.ZAddArgsIncr(ctx, ZAddArgs{
|
||||
// Members: []Z,
|
||||
// })
|
||||
// remove in v9.
|
||||
func (c cmdable) ZIncr(ctx context.Context, key string, member *Z) *FloatCmd {
|
||||
const n = 3
|
||||
a := make([]interface{}, n+2)
|
||||
a[0], a[1], a[2] = "zadd", key, "incr"
|
||||
return c.zIncr(ctx, a, n, member)
|
||||
return c.ZAddArgsIncr(ctx, key, ZAddArgs{
|
||||
Members: []Z{*member},
|
||||
})
|
||||
}
|
||||
|
||||
// Redis `ZADD key NX INCR score member` command.
|
||||
// ZIncrNX Redis `ZADD key NX INCR score member` command.
|
||||
// Deprecated: Use
|
||||
// client.ZAddArgsIncr(ctx, ZAddArgs{
|
||||
// NX: true,
|
||||
// Members: []Z,
|
||||
// })
|
||||
// remove in v9.
|
||||
func (c cmdable) ZIncrNX(ctx context.Context, key string, member *Z) *FloatCmd {
|
||||
const n = 4
|
||||
a := make([]interface{}, n+2)
|
||||
a[0], a[1], a[2], a[3] = "zadd", key, "incr", "nx"
|
||||
return c.zIncr(ctx, a, n, member)
|
||||
return c.ZAddArgsIncr(ctx, key, ZAddArgs{
|
||||
NX: true,
|
||||
Members: []Z{*member},
|
||||
})
|
||||
}
|
||||
|
||||
// Redis `ZADD key XX INCR score member` command.
|
||||
// ZIncrXX Redis `ZADD key XX INCR score member` command.
|
||||
// Deprecated: Use
|
||||
// client.ZAddArgsIncr(ctx, ZAddArgs{
|
||||
// XX: true,
|
||||
// Members: []Z,
|
||||
// })
|
||||
// remove in v9.
|
||||
func (c cmdable) ZIncrXX(ctx context.Context, key string, member *Z) *FloatCmd {
|
||||
const n = 4
|
||||
a := make([]interface{}, n+2)
|
||||
a[0], a[1], a[2], a[3] = "zadd", key, "incr", "xx"
|
||||
return c.zIncr(ctx, a, n, member)
|
||||
return c.ZAddArgsIncr(ctx, key, ZAddArgs{
|
||||
XX: true,
|
||||
Members: []Z{*member},
|
||||
})
|
||||
}
|
||||
|
||||
func (c cmdable) ZCard(ctx context.Context, key string) *IntCmd {
|
||||
|
@ -2104,18 +2337,7 @@ func (c cmdable) ZIncrBy(ctx context.Context, key string, increment float64, mem
|
|||
func (c cmdable) ZInterStore(ctx context.Context, destination string, store *ZStore) *IntCmd {
|
||||
args := make([]interface{}, 0, 3+store.len())
|
||||
args = append(args, "zinterstore", destination, len(store.Keys))
|
||||
for _, key := range store.Keys {
|
||||
args = append(args, key)
|
||||
}
|
||||
if len(store.Weights) > 0 {
|
||||
args = append(args, "weights")
|
||||
for _, weight := range store.Weights {
|
||||
args = append(args, weight)
|
||||
}
|
||||
}
|
||||
if store.Aggregate != "" {
|
||||
args = append(args, "aggregate", store.Aggregate)
|
||||
}
|
||||
args = store.appendArgs(args)
|
||||
cmd := NewIntCmd(ctx, args...)
|
||||
cmd.setFirstKeyPos(3)
|
||||
_ = c(ctx, cmd)
|
||||
|
@ -2125,19 +2347,7 @@ func (c cmdable) ZInterStore(ctx context.Context, destination string, store *ZSt
|
|||
func (c cmdable) ZInter(ctx context.Context, store *ZStore) *StringSliceCmd {
|
||||
args := make([]interface{}, 0, 2+store.len())
|
||||
args = append(args, "zinter", len(store.Keys))
|
||||
for _, key := range store.Keys {
|
||||
args = append(args, key)
|
||||
}
|
||||
if len(store.Weights) > 0 {
|
||||
args = append(args, "weights")
|
||||
for _, weights := range store.Weights {
|
||||
args = append(args, weights)
|
||||
}
|
||||
}
|
||||
|
||||
if store.Aggregate != "" {
|
||||
args = append(args, "aggregate", store.Aggregate)
|
||||
}
|
||||
args = store.appendArgs(args)
|
||||
cmd := NewStringSliceCmd(ctx, args...)
|
||||
cmd.setFirstKeyPos(2)
|
||||
_ = c(ctx, cmd)
|
||||
|
@ -2147,18 +2357,7 @@ func (c cmdable) ZInter(ctx context.Context, store *ZStore) *StringSliceCmd {
|
|||
func (c cmdable) ZInterWithScores(ctx context.Context, store *ZStore) *ZSliceCmd {
|
||||
args := make([]interface{}, 0, 3+store.len())
|
||||
args = append(args, "zinter", len(store.Keys))
|
||||
for _, key := range store.Keys {
|
||||
args = append(args, key)
|
||||
}
|
||||
if len(store.Weights) > 0 {
|
||||
args = append(args, "weights")
|
||||
for _, weights := range store.Weights {
|
||||
args = append(args, weights)
|
||||
}
|
||||
}
|
||||
if store.Aggregate != "" {
|
||||
args = append(args, "aggregate", store.Aggregate)
|
||||
}
|
||||
args = store.appendArgs(args)
|
||||
args = append(args, "withscores")
|
||||
cmd := NewZSliceCmd(ctx, args...)
|
||||
cmd.setFirstKeyPos(2)
|
||||
|
@ -2218,29 +2417,112 @@ func (c cmdable) ZPopMin(ctx context.Context, key string, count ...int64) *ZSlic
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) zRange(ctx context.Context, key string, start, stop int64, withScores bool) *StringSliceCmd {
|
||||
args := []interface{}{
|
||||
"zrange",
|
||||
key,
|
||||
start,
|
||||
stop,
|
||||
// ZRangeArgs is all the options of the ZRange command.
|
||||
// In version> 6.2.0, you can replace the(cmd):
|
||||
// ZREVRANGE,
|
||||
// ZRANGEBYSCORE,
|
||||
// ZREVRANGEBYSCORE,
|
||||
// ZRANGEBYLEX,
|
||||
// ZREVRANGEBYLEX.
|
||||
// Please pay attention to your redis-server version.
|
||||
//
|
||||
// Rev, ByScore, ByLex and Offset+Count options require redis-server 6.2.0 and higher.
|
||||
type ZRangeArgs struct {
|
||||
Key string
|
||||
|
||||
// When the ByScore option is provided, the open interval(exclusive) can be set.
|
||||
// By default, the score intervals specified by <Start> and <Stop> are closed (inclusive).
|
||||
// It is similar to the deprecated(6.2.0+) ZRangeByScore command.
|
||||
// For example:
|
||||
// ZRangeArgs{
|
||||
// Key: "example-key",
|
||||
// Start: "(3",
|
||||
// Stop: 8,
|
||||
// ByScore: true,
|
||||
// }
|
||||
// cmd: "ZRange example-key (3 8 ByScore" (3 < score <= 8).
|
||||
//
|
||||
// For the ByLex option, it is similar to the deprecated(6.2.0+) ZRangeByLex command.
|
||||
// You can set the <Start> and <Stop> options as follows:
|
||||
// ZRangeArgs{
|
||||
// Key: "example-key",
|
||||
// Start: "[abc",
|
||||
// Stop: "(def",
|
||||
// ByLex: true,
|
||||
// }
|
||||
// cmd: "ZRange example-key [abc (def ByLex"
|
||||
//
|
||||
// For normal cases (ByScore==false && ByLex==false), <Start> and <Stop> should be set to the index range (int).
|
||||
// You can read the documentation for more information: https://redis.io/commands/zrange
|
||||
Start interface{}
|
||||
Stop interface{}
|
||||
|
||||
// The ByScore and ByLex options are mutually exclusive.
|
||||
ByScore bool
|
||||
ByLex bool
|
||||
|
||||
Rev bool
|
||||
|
||||
// limit offset count.
|
||||
Offset int64
|
||||
Count int64
|
||||
}
|
||||
|
||||
func (z ZRangeArgs) appendArgs(args []interface{}) []interface{} {
|
||||
// For Rev+ByScore/ByLex, we need to adjust the position of <Start> and <Stop>.
|
||||
if z.Rev && (z.ByScore || z.ByLex) {
|
||||
args = append(args, z.Key, z.Stop, z.Start)
|
||||
} else {
|
||||
args = append(args, z.Key, z.Start, z.Stop)
|
||||
}
|
||||
if withScores {
|
||||
args = append(args, "withscores")
|
||||
|
||||
if z.ByScore {
|
||||
args = append(args, "byscore")
|
||||
} else if z.ByLex {
|
||||
args = append(args, "bylex")
|
||||
}
|
||||
if z.Rev {
|
||||
args = append(args, "rev")
|
||||
}
|
||||
if z.Offset != 0 || z.Count != 0 {
|
||||
args = append(args, "limit", z.Offset, z.Count)
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
func (c cmdable) ZRangeArgs(ctx context.Context, z ZRangeArgs) *StringSliceCmd {
|
||||
args := make([]interface{}, 0, 9)
|
||||
args = append(args, "zrange")
|
||||
args = z.appendArgs(args)
|
||||
cmd := NewStringSliceCmd(ctx, args...)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) ZRangeArgsWithScores(ctx context.Context, z ZRangeArgs) *ZSliceCmd {
|
||||
args := make([]interface{}, 0, 10)
|
||||
args = append(args, "zrange")
|
||||
args = z.appendArgs(args)
|
||||
args = append(args, "withscores")
|
||||
cmd := NewZSliceCmd(ctx, args...)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) ZRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd {
|
||||
return c.zRange(ctx, key, start, stop, false)
|
||||
return c.ZRangeArgs(ctx, ZRangeArgs{
|
||||
Key: key,
|
||||
Start: start,
|
||||
Stop: stop,
|
||||
})
|
||||
}
|
||||
|
||||
func (c cmdable) ZRangeWithScores(ctx context.Context, key string, start, stop int64) *ZSliceCmd {
|
||||
cmd := NewZSliceCmd(ctx, "zrange", key, start, stop, "withscores")
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
return c.ZRangeArgsWithScores(ctx, ZRangeArgs{
|
||||
Key: key,
|
||||
Start: start,
|
||||
Stop: stop,
|
||||
})
|
||||
}
|
||||
|
||||
type ZRangeBy struct {
|
||||
|
@ -2289,6 +2571,15 @@ func (c cmdable) ZRangeByScoreWithScores(ctx context.Context, key string, opt *Z
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) ZRangeStore(ctx context.Context, dst string, z ZRangeArgs) *IntCmd {
|
||||
args := make([]interface{}, 0, 10)
|
||||
args = append(args, "zrangestore", dst)
|
||||
args = z.appendArgs(args)
|
||||
cmd := NewIntCmd(ctx, args...)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) ZRank(ctx context.Context, key, member string) *IntCmd {
|
||||
cmd := NewIntCmd(ctx, "zrank", key, member)
|
||||
_ = c(ctx, cmd)
|
||||
|
@ -2391,29 +2682,38 @@ func (c cmdable) ZScore(ctx context.Context, key, member string) *FloatCmd {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) ZUnion(ctx context.Context, store ZStore) *StringSliceCmd {
|
||||
args := make([]interface{}, 0, 2+store.len())
|
||||
args = append(args, "zunion", len(store.Keys))
|
||||
args = store.appendArgs(args)
|
||||
cmd := NewStringSliceCmd(ctx, args...)
|
||||
cmd.setFirstKeyPos(2)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) ZUnionWithScores(ctx context.Context, store ZStore) *ZSliceCmd {
|
||||
args := make([]interface{}, 0, 3+store.len())
|
||||
args = append(args, "zunion", len(store.Keys))
|
||||
args = store.appendArgs(args)
|
||||
args = append(args, "withscores")
|
||||
cmd := NewZSliceCmd(ctx, args...)
|
||||
cmd.setFirstKeyPos(2)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) ZUnionStore(ctx context.Context, dest string, store *ZStore) *IntCmd {
|
||||
args := make([]interface{}, 0, 3+store.len())
|
||||
args = append(args, "zunionstore", dest, len(store.Keys))
|
||||
for _, key := range store.Keys {
|
||||
args = append(args, key)
|
||||
}
|
||||
if len(store.Weights) > 0 {
|
||||
args = append(args, "weights")
|
||||
for _, weight := range store.Weights {
|
||||
args = append(args, weight)
|
||||
}
|
||||
}
|
||||
if store.Aggregate != "" {
|
||||
args = append(args, "aggregate", store.Aggregate)
|
||||
}
|
||||
|
||||
args = store.appendArgs(args)
|
||||
cmd := NewIntCmd(ctx, args...)
|
||||
cmd.setFirstKeyPos(3)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// redis-server version >= 6.2.0.
|
||||
// ZRandMember redis-server version >= 6.2.0.
|
||||
func (c cmdable) ZRandMember(ctx context.Context, key string, count int, withScores bool) *StringSliceCmd {
|
||||
args := make([]interface{}, 0, 4)
|
||||
|
||||
|
@ -2428,7 +2728,7 @@ func (c cmdable) ZRandMember(ctx context.Context, key string, count int, withSco
|
|||
return cmd
|
||||
}
|
||||
|
||||
// redis-server version >= 6.2.0.
|
||||
// ZDiff redis-server version >= 6.2.0.
|
||||
func (c cmdable) ZDiff(ctx context.Context, keys ...string) *StringSliceCmd {
|
||||
args := make([]interface{}, 2+len(keys))
|
||||
args[0] = "zdiff"
|
||||
|
@ -2443,7 +2743,7 @@ func (c cmdable) ZDiff(ctx context.Context, keys ...string) *StringSliceCmd {
|
|||
return cmd
|
||||
}
|
||||
|
||||
// redis-server version >= 6.2.0.
|
||||
// ZDiffWithScores redis-server version >= 6.2.0.
|
||||
func (c cmdable) ZDiffWithScores(ctx context.Context, keys ...string) *ZSliceCmd {
|
||||
args := make([]interface{}, 3+len(keys))
|
||||
args[0] = "zdiff"
|
||||
|
@ -2459,7 +2759,7 @@ func (c cmdable) ZDiffWithScores(ctx context.Context, keys ...string) *ZSliceCmd
|
|||
return cmd
|
||||
}
|
||||
|
||||
// redis-server version >=6.2.0.
|
||||
// ZDiffStore redis-server version >=6.2.0.
|
||||
func (c cmdable) ZDiffStore(ctx context.Context, destination string, keys ...string) *IntCmd {
|
||||
args := make([]interface{}, 0, 3+len(keys))
|
||||
args = append(args, "zdiffstore", destination, len(keys))
|
||||
|
@ -2693,7 +2993,7 @@ func (c cmdable) SlowLogGet(ctx context.Context, num int64) *SlowLogCmd {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) Sync(ctx context.Context) {
|
||||
func (c cmdable) Sync(_ context.Context) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
|
@ -3011,7 +3311,7 @@ func (c cmdable) GeoRadiusStore(
|
|||
return cmd
|
||||
}
|
||||
|
||||
// GeoRadius is a read-only GEORADIUSBYMEMBER_RO command.
|
||||
// GeoRadiusByMember is a read-only GEORADIUSBYMEMBER_RO command.
|
||||
func (c cmdable) GeoRadiusByMember(
|
||||
ctx context.Context, key, member string, query *GeoRadiusQuery,
|
||||
) *GeoLocationCmd {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue