package redis

import (
	
	
	
	
)

type SortedSetCmdable interface {
	BZPopMax(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd
	BZPopMin(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd
	BZMPop(ctx context.Context, timeout time.Duration, order string, count int64, keys ...string) *ZSliceWithKeyCmd
	ZAdd(ctx context.Context, key string, members ...Z) *IntCmd
	ZAddLT(ctx context.Context, key string, members ...Z) *IntCmd
	ZAddGT(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
	ZAddArgs(ctx context.Context, key string, args ZAddArgs) *IntCmd
	ZAddArgsIncr(ctx context.Context, key string, args ZAddArgs) *FloatCmd
	ZCard(ctx context.Context, key string) *IntCmd
	ZCount(ctx context.Context, key, min, max string) *IntCmd
	ZLexCount(ctx context.Context, key, min, max string) *IntCmd
	ZIncrBy(ctx context.Context, key string, increment float64, member string) *FloatCmd
	ZInter(ctx context.Context, store *ZStore) *StringSliceCmd
	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
	ZRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd
	ZRangeWithScores(ctx context.Context, key string, start, stop int64) *ZSliceCmd
	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
	ZRankWithScore(ctx context.Context, key, member string) *RankWithScoreCmd
	ZRem(ctx context.Context, key string, members ...interface{}) *IntCmd
	ZRemRangeByRank(ctx context.Context, key string, start, stop int64) *IntCmd
	ZRemRangeByScore(ctx context.Context, key, min, max string) *IntCmd
	ZRemRangeByLex(ctx context.Context, key, min, max string) *IntCmd
	ZRevRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd
	ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) *ZSliceCmd
	ZRevRangeByScore(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd
	ZRevRangeByLex(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd
	ZRevRangeByScoreWithScores(ctx context.Context, key string, opt *ZRangeBy) *ZSliceCmd
	ZRevRank(ctx context.Context, key, member string) *IntCmd
	ZRevRankWithScore(ctx context.Context, key, member string) *RankWithScoreCmd
	ZScore(ctx context.Context, key, member string) *FloatCmd
	ZUnionStore(ctx context.Context, dest string, store *ZStore) *IntCmd
	ZRandMember(ctx context.Context, key string, count int) *StringSliceCmd
	ZRandMemberWithScores(ctx context.Context, key string, count int) *ZSliceCmd
	ZUnion(ctx context.Context, store ZStore) *StringSliceCmd
	ZUnionWithScores(ctx context.Context, store ZStore) *ZSliceCmd
	ZDiff(ctx context.Context, keys ...string) *StringSliceCmd
	ZDiffWithScores(ctx context.Context, keys ...string) *ZSliceCmd
	ZDiffStore(ctx context.Context, destination string, keys ...string) *IntCmd
	ZScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd
}

// BZPopMax Redis `BZPOPMAX key [key ...] timeout` command.
func ( cmdable) ( context.Context,  time.Duration,  ...string) *ZWithKeyCmd {
	 := make([]interface{}, 1+len()+1)
	[0] = "bzpopmax"
	for ,  := range  {
		[1+] = 
	}
	[len()-1] = formatSec(, )
	 := NewZWithKeyCmd(, ...)
	.setReadTimeout()
	_ = (, )
	return 
}

// BZPopMin Redis `BZPOPMIN key [key ...] timeout` command.
func ( cmdable) ( context.Context,  time.Duration,  ...string) *ZWithKeyCmd {
	 := make([]interface{}, 1+len()+1)
	[0] = "bzpopmin"
	for ,  := range  {
		[1+] = 
	}
	[len()-1] = formatSec(, )
	 := NewZWithKeyCmd(, ...)
	.setReadTimeout()
	_ = (, )
	return 
}

// BZMPop is the blocking variant of ZMPOP.
// When any of the sorted sets contains elements, this command behaves exactly like ZMPOP.
// When all sorted sets are empty, Redis will block the connection until another client adds members to one of the keys or until the timeout elapses.
// A timeout of zero can be used to block indefinitely.
// example: client.BZMPop(ctx, 0,"max", 1, "set")
func ( cmdable) ( context.Context,  time.Duration,  string,  int64,  ...string) *ZSliceWithKeyCmd {
	 := make([]interface{}, 3+len(), 6+len())
	[0] = "bzmpop"
	[1] = formatSec(, )
	[2] = len()
	for ,  := range  {
		[3+] = 
	}
	 = append(, strings.ToLower(), "count", )
	 := NewZSliceWithKeyCmd(, ...)
	// The key follows numkeys, not args[1]: route by it.
	if len() > 0 {
		.SetFirstKeyPos(3)
	}
	.setReadTimeout()
	_ = (, )
	return 
}

// 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 ( cmdable) ( string,  ZAddArgs,  bool) []interface{} {
	 := make([]interface{}, 0, 6+2*len(.Members))
	 = append(, "zadd", )

	// The GT, LT and NX options are mutually exclusive.
	if .NX {
		 = append(, "nx")
	} else {
		if .XX {
			 = append(, "xx")
		}
		if .GT {
			 = append(, "gt")
		} else if .LT {
			 = append(, "lt")
		}
	}
	if .Ch {
		 = append(, "ch")
	}
	if  {
		 = append(, "incr")
	}
	for ,  := range .Members {
		 = append(, .Score)
		 = append(, .Member)
	}
	return 
}

func ( cmdable) ( context.Context,  string,  ZAddArgs) *IntCmd {
	 := NewIntCmd(, .zAddArgs(, , false)...)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  string,  ZAddArgs) *FloatCmd {
	 := NewFloatCmd(, .zAddArgs(, , true)...)
	_ = (, )
	return 
}

// ZAdd Redis `ZADD key score member [score member ...]` command.
func ( cmdable) ( context.Context,  string,  ...Z) *IntCmd {
	return .ZAddArgs(, , ZAddArgs{
		Members: ,
	})
}

// ZAddLT Redis `ZADD key LT score member [score member ...]` command.
func ( cmdable) ( context.Context,  string,  ...Z) *IntCmd {
	return .ZAddArgs(, , ZAddArgs{
		LT:      true,
		Members: ,
	})
}

// ZAddGT Redis `ZADD key GT score member [score member ...]` command.
func ( cmdable) ( context.Context,  string,  ...Z) *IntCmd {
	return .ZAddArgs(, , ZAddArgs{
		GT:      true,
		Members: ,
	})
}

// ZAddNX Redis `ZADD key NX score member [score member ...]` command.
func ( cmdable) ( context.Context,  string,  ...Z) *IntCmd {
	return .ZAddArgs(, , ZAddArgs{
		NX:      true,
		Members: ,
	})
}

// ZAddXX Redis `ZADD key XX score member [score member ...]` command.
func ( cmdable) ( context.Context,  string,  ...Z) *IntCmd {
	return .ZAddArgs(, , ZAddArgs{
		XX:      true,
		Members: ,
	})
}

func ( cmdable) ( context.Context,  string) *IntCmd {
	 := NewIntCmd(, "zcard", )
	_ = (, )
	return 
}

func ( cmdable) ( context.Context, , ,  string) *IntCmd {
	 := NewIntCmd(, "zcount", , , )
	_ = (, )
	return 
}

func ( cmdable) ( context.Context, , ,  string) *IntCmd {
	 := NewIntCmd(, "zlexcount", , , )
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  string,  float64,  string) *FloatCmd {
	 := NewFloatCmd(, "zincrby", , , )
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  string,  *ZStore) *IntCmd {
	 := make([]interface{}, 0, 3+.len())
	 = append(, "zinterstore", , len(.Keys))
	 = .appendArgs()
	 := NewIntCmd(, ...)
	.SetFirstKeyPos(3)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  *ZStore) *StringSliceCmd {
	 := make([]interface{}, 0, 2+.len())
	 = append(, "zinter", len(.Keys))
	 = .appendArgs()
	 := NewStringSliceCmd(, ...)
	.SetFirstKeyPos(2)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  *ZStore) *ZSliceCmd {
	 := make([]interface{}, 0, 3+.len())
	 = append(, "zinter", len(.Keys))
	 = .appendArgs()
	 = append(, "withscores")
	 := NewZSliceCmd(, ...)
	.SetFirstKeyPos(2)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  int64,  ...string) *IntCmd {
	 := len()
	 := make([]interface{}, 4+)
	[0] = "zintercard"
	[1] = 
	for ,  := range  {
		[2+] = 
	}
	[2+] = "limit"
	[3+] = 
	 := NewIntCmd(, ...)
	// The key follows numkeys, not args[1]: route by it.
	if len() > 0 {
		.SetFirstKeyPos(2)
	}
	_ = (, )
	return 
}

// 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 ( cmdable) ( context.Context,  string,  int64,  ...string) *ZSliceWithKeyCmd {
	 := make([]interface{}, 2+len(), 5+len())
	[0] = "zmpop"
	[1] = len()
	for ,  := range  {
		[2+] = 
	}
	 = append(, strings.ToLower(), "count", )
	 := NewZSliceWithKeyCmd(, ...)
	// The key follows numkeys, not args[1]: route by it.
	if len() > 0 {
		.SetFirstKeyPos(2)
	}
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  string,  ...string) *FloatSliceCmd {
	 := make([]interface{}, 2+len())
	[0] = "zmscore"
	[1] = 
	for ,  := range  {
		[2+] = 
	}
	 := NewFloatSliceCmd(, ...)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  string,  ...int64) *ZSliceCmd {
	 := []interface{}{
		"zpopmax",
		,
	}

	switch len() {
	case 0:
		break
	case 1:
		 = append(, [0])
	default:
		 := NewZSliceCmd()
		.SetErr(errors.New("too many arguments"))
		return 
	}

	 := NewZSliceCmd(, ...)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  string,  ...int64) *ZSliceCmd {
	 := []interface{}{
		"zpopmin",
		,
	}

	switch len() {
	case 0:
		break
	case 1:
		 = append(, [0])
	default:
		 := NewZSliceCmd()
		.SetErr(errors.New("too many arguments"))
		return 
	}

	 := NewZSliceCmd(, ...)
	_ = (, )
	return 
}

// 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).
	//
	// When the Rev option is also provided, <Start> should be the higher score value and
	// <Stop> should be the lower score value (i.e. reversed order):
	//		ZRangeArgs{
	//			Key: 				"example-key",
	//	 		Start: 				8,
	//	 		Stop: 				"(3",
	//			ByScore:			true,
	//			Rev:				true,
	//	 	}
	// 	 	cmd: "ZRange example-key 8 (3 ByScore Rev"  (8 >= score > 3, in reverse order).
	//
	// 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"
	//
	// When the Rev option is also provided, <Start> should be the lexicographically higher
	// value and <Stop> should be the lower value:
	//		ZRangeArgs{
	//			Key: 				"example-key",
	//	 		Start: 				"(def",
	//	 		Stop: 				"[abc",
	//			ByLex:				true,
	//			Rev:				true,
	//	 	}
	//		cmd: "ZRange example-key (def [abc ByLex Rev"
	//
	// 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 ( ZRangeArgs) ( []interface{}) []interface{} {
	 = append(, .Key, .Start, .Stop)

	if .ByScore {
		 = append(, "byscore")
	} else if .ByLex {
		 = append(, "bylex")
	}
	if .Rev {
		 = append(, "rev")
	}
	if .Offset != 0 || .Count != 0 {
		 = append(, "limit", .Offset, .Count)
	}
	return 
}

func ( cmdable) ( context.Context,  ZRangeArgs) *StringSliceCmd {
	 := make([]interface{}, 0, 9)
	 = append(, "zrange")
	 = .appendArgs()
	 := NewStringSliceCmd(, ...)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  ZRangeArgs) *ZSliceCmd {
	 := make([]interface{}, 0, 10)
	 = append(, "zrange")
	 = .appendArgs()
	 = append(, "withscores")
	 := NewZSliceCmd(, ...)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  string, ,  int64) *StringSliceCmd {
	return .ZRangeArgs(, ZRangeArgs{
		Key:   ,
		Start: ,
		Stop:  ,
	})
}

func ( cmdable) ( context.Context,  string, ,  int64) *ZSliceCmd {
	return .ZRangeArgsWithScores(, ZRangeArgs{
		Key:   ,
		Start: ,
		Stop:  ,
	})
}

type ZRangeBy struct {
	Min, Max      string
	Offset, Count int64
}

func ( cmdable) ( context.Context, ,  string,  *ZRangeBy,  bool) *StringSliceCmd {
	 := []interface{}{, , .Min, .Max}
	if  {
		 = append(, "withscores")
	}
	if .Offset != 0 || .Count != 0 {
		 = append(
			,
			"limit",
			.Offset,
			.Count,
		)
	}
	 := NewStringSliceCmd(, ...)
	_ = (, )
	return 
}

// ZRangeByScore returns members in a sorted set within a range of scores.
//
// Deprecated: Use ZRangeArgs with ByScore option instead as of Redis 6.2.0.
func ( cmdable) ( context.Context,  string,  *ZRangeBy) *StringSliceCmd {
	return .zRangeBy(, "zrangebyscore", , , false)
}

// ZRangeByLex returns members in a sorted set within a lexicographical range.
//
// Deprecated: Use ZRangeArgs with ByLex option instead as of Redis 6.2.0.
func ( cmdable) ( context.Context,  string,  *ZRangeBy) *StringSliceCmd {
	return .zRangeBy(, "zrangebylex", , , false)
}

func ( cmdable) ( context.Context,  string,  *ZRangeBy) *ZSliceCmd {
	 := []interface{}{"zrangebyscore", , .Min, .Max, "withscores"}
	if .Offset != 0 || .Count != 0 {
		 = append(
			,
			"limit",
			.Offset,
			.Count,
		)
	}
	 := NewZSliceCmd(, ...)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  string,  ZRangeArgs) *IntCmd {
	 := make([]interface{}, 0, 10)
	 = append(, "zrangestore", )
	 = .appendArgs()
	 := NewIntCmd(, ...)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context, ,  string) *IntCmd {
	 := NewIntCmd(, "zrank", , )
	_ = (, )
	return 
}

// ZRankWithScore according to the Redis documentation, if member does not exist
// in the sorted set or key does not exist, it will return a redis.Nil error.
func ( cmdable) ( context.Context, ,  string) *RankWithScoreCmd {
	 := NewRankWithScoreCmd(, "zrank", , , "withscore")
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  string,  ...interface{}) *IntCmd {
	 := make([]interface{}, 2, 2+len())
	[0] = "zrem"
	[1] = 
	 = appendArgs(, )
	 := NewIntCmd(, ...)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  string, ,  int64) *IntCmd {
	 := NewIntCmd(
		,
		"zremrangebyrank",
		,
		,
		,
	)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context, , ,  string) *IntCmd {
	 := NewIntCmd(, "zremrangebyscore", , , )
	_ = (, )
	return 
}

func ( cmdable) ( context.Context, , ,  string) *IntCmd {
	 := NewIntCmd(, "zremrangebylex", , , )
	_ = (, )
	return 
}

// ZRevRange returns members in a sorted set within a range of indexes in reverse order.
//
// Deprecated: Use ZRangeArgs with Rev option instead as of Redis 6.2.0.
func ( cmdable) ( context.Context,  string, ,  int64) *StringSliceCmd {
	 := NewStringSliceCmd(, "zrevrange", , , )
	_ = (, )
	return 
}

// ZRevRangeWithScores according to the Redis documentation, if member does not exist
// in the sorted set or key does not exist, it will return a redis.Nil error.
func ( cmdable) ( context.Context,  string, ,  int64) *ZSliceCmd {
	 := NewZSliceCmd(, "zrevrange", , , , "withscores")
	_ = (, )
	return 
}

func ( cmdable) ( context.Context, ,  string,  *ZRangeBy) *StringSliceCmd {
	 := []interface{}{, , .Max, .Min}
	if .Offset != 0 || .Count != 0 {
		 = append(
			,
			"limit",
			.Offset,
			.Count,
		)
	}
	 := NewStringSliceCmd(, ...)
	_ = (, )
	return 
}

// ZRevRangeByScore returns members in a sorted set within a range of scores in reverse order.
//
// Deprecated: Use ZRangeArgs with Rev and ByScore options instead as of Redis 6.2.0.
func ( cmdable) ( context.Context,  string,  *ZRangeBy) *StringSliceCmd {
	return .zRevRangeBy(, "zrevrangebyscore", , )
}

// ZRevRangeByLex returns members in a sorted set within a lexicographical range in reverse order.
//
// Deprecated: Use ZRangeArgs with Rev and ByLex options instead as of Redis 6.2.0.
func ( cmdable) ( context.Context,  string,  *ZRangeBy) *StringSliceCmd {
	return .zRevRangeBy(, "zrevrangebylex", , )
}

func ( cmdable) ( context.Context,  string,  *ZRangeBy) *ZSliceCmd {
	 := []interface{}{"zrevrangebyscore", , .Max, .Min, "withscores"}
	if .Offset != 0 || .Count != 0 {
		 = append(
			,
			"limit",
			.Offset,
			.Count,
		)
	}
	 := NewZSliceCmd(, ...)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context, ,  string) *IntCmd {
	 := NewIntCmd(, "zrevrank", , )
	_ = (, )
	return 
}

func ( cmdable) ( context.Context, ,  string) *RankWithScoreCmd {
	 := NewRankWithScoreCmd(, "zrevrank", , , "withscore")
	_ = (, )
	return 
}

func ( cmdable) ( context.Context, ,  string) *FloatCmd {
	 := NewFloatCmd(, "zscore", , )
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  ZStore) *StringSliceCmd {
	 := make([]interface{}, 0, 2+.len())
	 = append(, "zunion", len(.Keys))
	 = .appendArgs()
	 := NewStringSliceCmd(, ...)
	.SetFirstKeyPos(2)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  ZStore) *ZSliceCmd {
	 := make([]interface{}, 0, 3+.len())
	 = append(, "zunion", len(.Keys))
	 = .appendArgs()
	 = append(, "withscores")
	 := NewZSliceCmd(, ...)
	.SetFirstKeyPos(2)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  string,  *ZStore) *IntCmd {
	 := make([]interface{}, 0, 3+.len())
	 = append(, "zunionstore", , len(.Keys))
	 = .appendArgs()
	 := NewIntCmd(, ...)
	.SetFirstKeyPos(3)
	_ = (, )
	return 
}

// ZRandMember redis-server version >= 6.2.0.
func ( cmdable) ( context.Context,  string,  int) *StringSliceCmd {
	 := NewStringSliceCmd(, "zrandmember", , )
	_ = (, )
	return 
}

// ZRandMemberWithScores redis-server version >= 6.2.0.
func ( cmdable) ( context.Context,  string,  int) *ZSliceCmd {
	 := NewZSliceCmd(, "zrandmember", , , "withscores")
	_ = (, )
	return 
}

// ZDiff redis-server version >= 6.2.0.
func ( cmdable) ( context.Context,  ...string) *StringSliceCmd {
	 := make([]interface{}, 2+len())
	[0] = "zdiff"
	[1] = len()
	for ,  := range  {
		[+2] = 
	}

	 := NewStringSliceCmd(, ...)
	.SetFirstKeyPos(2)
	_ = (, )
	return 
}

// ZDiffWithScores redis-server version >= 6.2.0.
func ( cmdable) ( context.Context,  ...string) *ZSliceCmd {
	 := make([]interface{}, 3+len())
	[0] = "zdiff"
	[1] = len()
	for ,  := range  {
		[+2] = 
	}
	[len()+2] = "withscores"

	 := NewZSliceCmd(, ...)
	.SetFirstKeyPos(2)
	_ = (, )
	return 
}

// ZDiffStore redis-server version >=6.2.0.
func ( cmdable) ( context.Context,  string,  ...string) *IntCmd {
	 := make([]interface{}, 0, 3+len())
	 = append(, "zdiffstore", , len())
	for ,  := range  {
		 = append(, )
	}
	 := NewIntCmd(, ...)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  string,  uint64,  string,  int64) *ScanCmd {
	 := []interface{}{"zscan", , }
	if  != "" {
		 = append(, "match", )
	}
	if  > 0 {
		 = append(, "count", )
	}
	 := NewScanCmd(, , ...)
	_ = (, )
	return 
}

// Z represents sorted set member.
type Z struct {
	Score  float64
	Member interface{}
}

// ZWithKey represents sorted set member including the name of the key where it was popped.
type ZWithKey struct {
	Z
	Key string
}

// ZStore is used as an arg to ZInter/ZInterStore and ZUnion/ZUnionStore.
type ZStore struct {
	Keys    []string
	Weights []float64
	// Can be SUM, MIN, MAX or COUNT.
	Aggregate string
}

func ( ZStore) () ( int) {
	 = len(.Keys)
	if len(.Weights) > 0 {
		 += 1 + len(.Weights)
	}
	if .Aggregate != "" {
		 += 2
	}
	return 
}

func ( ZStore) ( []interface{}) []interface{} {
	for ,  := range .Keys {
		 = append(, )
	}
	if len(.Weights) > 0 {
		 = append(, "weights")
		for ,  := range .Weights {
			 = append(, )
		}
	}
	if .Aggregate != "" {
		 = append(, "aggregate", .Aggregate)
	}
	return 
}