Source File
commands.go
Belonging Package
github.com/go-redis/redis/v8
package redis
import (
)
func ( time.Duration) bool {
return < time.Second || %time.Second != 0
}
func ( context.Context, time.Duration) int64 {
if > 0 && < time.Millisecond {
internal.Logger.Printf(
,
"specified duration is %s, but minimal supported value is %s - truncating to 1ms",
, time.Millisecond,
)
return 1
}
return int64( / time.Millisecond)
}
func ( context.Context, time.Duration) int64 {
if > 0 && < time.Second {
internal.Logger.Printf(
,
"specified duration is %s, but minimal supported value is %s - truncating to 1s",
, time.Second,
)
return 1
}
return int64( / time.Second)
}
func (, []interface{}) []interface{} {
if len() == 1 {
return appendArg(, [0])
}
= append(, ...)
return
}
func ( []interface{}, interface{}) []interface{} {
switch arg := .(type) {
case []string:
for , := range {
= append(, )
}
return
case []interface{}:
= append(, ...)
return
case map[string]interface{}:
for , := range {
= append(, , )
}
return
default:
return append(, )
}
}
type Cmdable interface {
Pipeline() Pipeliner
Pipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)
TxPipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)
TxPipeline() Pipeliner
Command(ctx context.Context) *CommandsInfoCmd
ClientGetName(ctx context.Context) *StringCmd
Echo(ctx context.Context, message interface{}) *StringCmd
Ping(ctx context.Context) *StatusCmd
Quit(ctx context.Context) *StatusCmd
Del(ctx context.Context, keys ...string) *IntCmd
Unlink(ctx context.Context, keys ...string) *IntCmd
Dump(ctx context.Context, key string) *StringCmd
Exists(ctx context.Context, keys ...string) *IntCmd
Expire(ctx context.Context, key string, expiration time.Duration) *BoolCmd
ExpireAt(ctx context.Context, key string, tm time.Time) *BoolCmd
Keys(ctx context.Context, pattern string) *StringSliceCmd
Migrate(ctx context.Context, host, port, key string, db int, timeout time.Duration) *StatusCmd
Move(ctx context.Context, key string, db int) *BoolCmd
ObjectRefCount(ctx context.Context, key string) *IntCmd
ObjectEncoding(ctx context.Context, key string) *StringCmd
ObjectIdleTime(ctx context.Context, key string) *DurationCmd
Persist(ctx context.Context, key string) *BoolCmd
PExpire(ctx context.Context, key string, expiration time.Duration) *BoolCmd
PExpireAt(ctx context.Context, key string, tm time.Time) *BoolCmd
PTTL(ctx context.Context, key string) *DurationCmd
RandomKey(ctx context.Context) *StringCmd
Rename(ctx context.Context, key, newkey string) *StatusCmd
RenameNX(ctx context.Context, key, newkey string) *BoolCmd
Restore(ctx context.Context, key string, ttl time.Duration, value string) *StatusCmd
RestoreReplace(ctx context.Context, key string, ttl time.Duration, value string) *StatusCmd
Sort(ctx context.Context, key string, sort *Sort) *StringSliceCmd
SortStore(ctx context.Context, key, store string, sort *Sort) *IntCmd
SortInterfaces(ctx context.Context, key string, sort *Sort) *SliceCmd
Touch(ctx context.Context, keys ...string) *IntCmd
TTL(ctx context.Context, key string) *DurationCmd
Type(ctx context.Context, key string) *StatusCmd
Append(ctx context.Context, key, value string) *IntCmd
Decr(ctx context.Context, key string) *IntCmd
DecrBy(ctx context.Context, key string, decrement int64) *IntCmd
Get(ctx context.Context, key string) *StringCmd
GetRange(ctx context.Context, key string, start, end int64) *StringCmd
GetSet(ctx context.Context, key string, value interface{}) *StringCmd
Incr(ctx context.Context, key string) *IntCmd
IncrBy(ctx context.Context, key string, value int64) *IntCmd
IncrByFloat(ctx context.Context, key string, value float64) *FloatCmd
MGet(ctx context.Context, keys ...string) *SliceCmd
MSet(ctx context.Context, values ...interface{}) *StatusCmd
MSetNX(ctx context.Context, values ...interface{}) *BoolCmd
Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd
SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd
SetXX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd
SetRange(ctx context.Context, key string, offset int64, value string) *IntCmd
StrLen(ctx context.Context, key string) *IntCmd
GetBit(ctx context.Context, key string, offset int64) *IntCmd
SetBit(ctx context.Context, key string, offset int64, value int) *IntCmd
BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd
BitOpAnd(ctx context.Context, destKey string, keys ...string) *IntCmd
BitOpOr(ctx context.Context, destKey string, keys ...string) *IntCmd
BitOpXor(ctx context.Context, destKey string, keys ...string) *IntCmd
BitOpNot(ctx context.Context, destKey string, key string) *IntCmd
BitPos(ctx context.Context, key string, bit int64, pos ...int64) *IntCmd
BitField(ctx context.Context, key string, args ...interface{}) *IntSliceCmd
Scan(ctx context.Context, cursor uint64, match string, count int64) *ScanCmd
SScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd
HScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd
ZScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd
HDel(ctx context.Context, key string, fields ...string) *IntCmd
HExists(ctx context.Context, key, field string) *BoolCmd
HGet(ctx context.Context, key, field string) *StringCmd
HGetAll(ctx context.Context, key string) *StringStringMapCmd
HIncrBy(ctx context.Context, key, field string, incr int64) *IntCmd
HIncrByFloat(ctx context.Context, key, field string, incr float64) *FloatCmd
HKeys(ctx context.Context, key string) *StringSliceCmd
HLen(ctx context.Context, key string) *IntCmd
HMGet(ctx context.Context, key string, fields ...string) *SliceCmd
HSet(ctx context.Context, key string, values ...interface{}) *IntCmd
HMSet(ctx context.Context, key string, values ...interface{}) *BoolCmd
HSetNX(ctx context.Context, key, field string, value interface{}) *BoolCmd
HVals(ctx context.Context, key string) *StringSliceCmd
BLPop(ctx context.Context, timeout time.Duration, keys ...string) *StringSliceCmd
BRPop(ctx context.Context, timeout time.Duration, keys ...string) *StringSliceCmd
BRPopLPush(ctx context.Context, source, destination string, timeout time.Duration) *StringCmd
LIndex(ctx context.Context, key string, index int64) *StringCmd
LInsert(ctx context.Context, key, op string, pivot, value interface{}) *IntCmd
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
LPop(ctx context.Context, key string) *StringCmd
LPush(ctx context.Context, key string, values ...interface{}) *IntCmd
LPushX(ctx context.Context, key string, values ...interface{}) *IntCmd
LRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd
LRem(ctx context.Context, key string, count int64, value interface{}) *IntCmd
LSet(ctx context.Context, key string, index int64, value interface{}) *StatusCmd
LTrim(ctx context.Context, key string, start, stop int64) *StatusCmd
RPop(ctx context.Context, key string) *StringCmd
RPopLPush(ctx context.Context, source, destination string) *StringCmd
RPush(ctx context.Context, key string, values ...interface{}) *IntCmd
RPushX(ctx context.Context, key string, values ...interface{}) *IntCmd
SAdd(ctx context.Context, key string, members ...interface{}) *IntCmd
SCard(ctx context.Context, key string) *IntCmd
SDiff(ctx context.Context, keys ...string) *StringSliceCmd
SDiffStore(ctx context.Context, destination string, keys ...string) *IntCmd
SInter(ctx context.Context, keys ...string) *StringSliceCmd
SInterStore(ctx context.Context, destination string, keys ...string) *IntCmd
SIsMember(ctx context.Context, key string, member interface{}) *BoolCmd
SMembers(ctx context.Context, key string) *StringSliceCmd
SMembersMap(ctx context.Context, key string) *StringStructMapCmd
SMove(ctx context.Context, source, destination string, member interface{}) *BoolCmd
SPop(ctx context.Context, key string) *StringCmd
SPopN(ctx context.Context, key string, count int64) *StringSliceCmd
SRandMember(ctx context.Context, key string) *StringCmd
SRandMemberN(ctx context.Context, key string, count int64) *StringSliceCmd
SRem(ctx context.Context, key string, members ...interface{}) *IntCmd
SUnion(ctx context.Context, keys ...string) *StringSliceCmd
SUnionStore(ctx context.Context, destination string, keys ...string) *IntCmd
XAdd(ctx context.Context, a *XAddArgs) *StringCmd
XDel(ctx context.Context, stream string, ids ...string) *IntCmd
XLen(ctx context.Context, stream string) *IntCmd
XRange(ctx context.Context, stream, start, stop string) *XMessageSliceCmd
XRangeN(ctx context.Context, stream, start, stop string, count int64) *XMessageSliceCmd
XRevRange(ctx context.Context, stream string, start, stop string) *XMessageSliceCmd
XRevRangeN(ctx context.Context, stream string, start, stop string, count int64) *XMessageSliceCmd
XRead(ctx context.Context, a *XReadArgs) *XStreamSliceCmd
XReadStreams(ctx context.Context, streams ...string) *XStreamSliceCmd
XGroupCreate(ctx context.Context, stream, group, start string) *StatusCmd
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
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
XPending(ctx context.Context, stream, group string) *XPendingCmd
XPendingExt(ctx context.Context, a *XPendingExtArgs) *XPendingExtCmd
XClaim(ctx context.Context, a *XClaimArgs) *XMessageSliceCmd
XClaimJustID(ctx context.Context, a *XClaimArgs) *StringSliceCmd
XTrim(ctx context.Context, key string, maxLen int64) *IntCmd
XTrimApprox(ctx context.Context, key string, maxLen int64) *IntCmd
XInfoGroups(ctx context.Context, key string) *XInfoGroupsCmd
BZPopMax(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd
BZPopMin(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd
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
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
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
ZInterStore(ctx context.Context, destination string, store *ZStore) *IntCmd
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
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
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
ZScore(ctx context.Context, key, member string) *FloatCmd
ZUnionStore(ctx context.Context, dest string, store *ZStore) *IntCmd
PFAdd(ctx context.Context, key string, els ...interface{}) *IntCmd
PFCount(ctx context.Context, keys ...string) *IntCmd
PFMerge(ctx context.Context, dest string, keys ...string) *StatusCmd
BgRewriteAOF(ctx context.Context) *StatusCmd
BgSave(ctx context.Context) *StatusCmd
ClientKill(ctx context.Context, ipPort string) *StatusCmd
ClientKillByFilter(ctx context.Context, keys ...string) *IntCmd
ClientList(ctx context.Context) *StringCmd
ClientPause(ctx context.Context, dur time.Duration) *BoolCmd
ClientID(ctx context.Context) *IntCmd
ConfigGet(ctx context.Context, parameter string) *SliceCmd
ConfigResetStat(ctx context.Context) *StatusCmd
ConfigSet(ctx context.Context, parameter, value string) *StatusCmd
ConfigRewrite(ctx context.Context) *StatusCmd
DBSize(ctx context.Context) *IntCmd
FlushAll(ctx context.Context) *StatusCmd
FlushAllAsync(ctx context.Context) *StatusCmd
FlushDB(ctx context.Context) *StatusCmd
FlushDBAsync(ctx context.Context) *StatusCmd
Info(ctx context.Context, section ...string) *StringCmd
LastSave(ctx context.Context) *IntCmd
Save(ctx context.Context) *StatusCmd
Shutdown(ctx context.Context) *StatusCmd
ShutdownSave(ctx context.Context) *StatusCmd
ShutdownNoSave(ctx context.Context) *StatusCmd
SlaveOf(ctx context.Context, host, port string) *StatusCmd
Time(ctx context.Context) *TimeCmd
DebugObject(ctx context.Context, key string) *StringCmd
ReadOnly(ctx context.Context) *StatusCmd
ReadWrite(ctx context.Context) *StatusCmd
MemoryUsage(ctx context.Context, key string, samples ...int) *IntCmd
Eval(ctx context.Context, script string, keys []string, args ...interface{}) *Cmd
EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *Cmd
ScriptExists(ctx context.Context, hashes ...string) *BoolSliceCmd
ScriptFlush(ctx context.Context) *StatusCmd
ScriptKill(ctx context.Context) *StatusCmd
ScriptLoad(ctx context.Context, script string) *StringCmd
Publish(ctx context.Context, channel string, message interface{}) *IntCmd
PubSubChannels(ctx context.Context, pattern string) *StringSliceCmd
PubSubNumSub(ctx context.Context, channels ...string) *StringIntMapCmd
PubSubNumPat(ctx context.Context) *IntCmd
ClusterSlots(ctx context.Context) *ClusterSlotsCmd
ClusterNodes(ctx context.Context) *StringCmd
ClusterMeet(ctx context.Context, host, port string) *StatusCmd
ClusterForget(ctx context.Context, nodeID string) *StatusCmd
ClusterReplicate(ctx context.Context, nodeID string) *StatusCmd
ClusterResetSoft(ctx context.Context) *StatusCmd
ClusterResetHard(ctx context.Context) *StatusCmd
ClusterInfo(ctx context.Context) *StringCmd
ClusterKeySlot(ctx context.Context, key string) *IntCmd
ClusterGetKeysInSlot(ctx context.Context, slot int, count int) *StringSliceCmd
ClusterCountFailureReports(ctx context.Context, nodeID string) *IntCmd
ClusterCountKeysInSlot(ctx context.Context, slot int) *IntCmd
ClusterDelSlots(ctx context.Context, slots ...int) *StatusCmd
ClusterDelSlotsRange(ctx context.Context, min, max int) *StatusCmd
ClusterSaveConfig(ctx context.Context) *StatusCmd
ClusterSlaves(ctx context.Context, nodeID string) *StringSliceCmd
ClusterFailover(ctx context.Context) *StatusCmd
ClusterAddSlots(ctx context.Context, slots ...int) *StatusCmd
ClusterAddSlotsRange(ctx context.Context, min, max int) *StatusCmd
GeoAdd(ctx context.Context, key string, geoLocation ...*GeoLocation) *IntCmd
GeoPos(ctx context.Context, key string, members ...string) *GeoPosCmd
GeoRadius(ctx context.Context, key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd
GeoRadiusStore(ctx context.Context, key string, longitude, latitude float64, query *GeoRadiusQuery) *IntCmd
GeoRadiusByMember(ctx context.Context, key, member string, query *GeoRadiusQuery) *GeoLocationCmd
GeoRadiusByMemberStore(ctx context.Context, key, member string, query *GeoRadiusQuery) *IntCmd
GeoDist(ctx context.Context, key string, member1, member2, unit string) *FloatCmd
GeoHash(ctx context.Context, key string, members ...string) *StringSliceCmd
}
type StatefulCmdable interface {
Cmdable
Auth(ctx context.Context, password string) *StatusCmd
AuthACL(ctx context.Context, username, password string) *StatusCmd
Select(ctx context.Context, index int) *StatusCmd
SwapDB(ctx context.Context, index1, index2 int) *StatusCmd
ClientSetName(ctx context.Context, name string) *BoolCmd
}
var (
_ Cmdable = (*Client)(nil)
_ Cmdable = (*Tx)(nil)
_ Cmdable = (*Ring)(nil)
_ Cmdable = (*ClusterClient)(nil)
)
type cmdable func(ctx context.Context, cmd Cmder) error
type statefulCmdable func(ctx context.Context, cmd Cmder) error
func ( statefulCmdable) ( context.Context, string) *StatusCmd {
:= NewStatusCmd(, "auth", )
_ = (, )
return
}
func ( statefulCmdable) ( context.Context, , string) *StatusCmd {
:= NewStatusCmd(, "auth", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, int, time.Duration) *IntCmd {
:= NewIntCmd(, "wait", , int(/time.Millisecond))
_ = (, )
return
}
func ( statefulCmdable) ( context.Context, int) *StatusCmd {
:= NewStatusCmd(, "select", )
_ = (, )
return
}
func ( statefulCmdable) ( context.Context, , int) *StatusCmd {
:= NewStatusCmd(, "swapdb", , )
_ = (, )
return
}
func ( statefulCmdable) ( context.Context, string) *BoolCmd {
:= NewBoolCmd(, "client", "setname", )
_ = (, )
return
}
func ( cmdable) ( context.Context) *CommandsInfoCmd {
:= NewCommandsInfoCmd(, "command")
_ = (, )
return
}
func ( cmdable) ( context.Context) *StringCmd {
:= NewStringCmd(, "client", "getname")
_ = (, )
return
}
func ( cmdable) ( context.Context, interface{}) *StringCmd {
:= NewStringCmd(, "echo", )
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "ping")
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
panic("not implemented")
}
func ( cmdable) ( context.Context, ...string) *IntCmd {
:= make([]interface{}, 1+len())
[0] = "del"
for , := range {
[1+] =
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, ...string) *IntCmd {
:= make([]interface{}, 1+len())
[0] = "unlink"
for , := range {
[1+] =
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StringCmd {
:= NewStringCmd(, "dump", )
_ = (, )
return
}
func ( cmdable) ( context.Context, ...string) *IntCmd {
:= make([]interface{}, 1+len())
[0] = "exists"
for , := range {
[1+] =
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, time.Duration) *BoolCmd {
:= NewBoolCmd(, "expire", , formatSec(, ))
_ = (, )
return
}
func ( cmdable) ( context.Context, string, time.Time) *BoolCmd {
:= NewBoolCmd(, "expireat", , .Unix())
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StringSliceCmd {
:= NewStringSliceCmd(, "keys", )
_ = (, )
return
}
func ( cmdable) ( context.Context, , , string, int, time.Duration) *StatusCmd {
:= NewStatusCmd(
,
"migrate",
,
,
,
,
formatMs(, ),
)
.setReadTimeout()
_ = (, )
return
}
func ( cmdable) ( context.Context, string, int) *BoolCmd {
:= NewBoolCmd(, "move", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *IntCmd {
:= NewIntCmd(, "object", "refcount", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StringCmd {
:= NewStringCmd(, "object", "encoding", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *DurationCmd {
:= NewDurationCmd(, time.Second, "object", "idletime", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *BoolCmd {
:= NewBoolCmd(, "persist", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, time.Duration) *BoolCmd {
:= NewBoolCmd(, "pexpire", , formatMs(, ))
_ = (, )
return
}
func ( cmdable) ( context.Context, string, time.Time) *BoolCmd {
:= NewBoolCmd(
,
"pexpireat",
,
.UnixNano()/int64(time.Millisecond),
)
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *DurationCmd {
:= NewDurationCmd(, time.Millisecond, "pttl", )
_ = (, )
return
}
func ( cmdable) ( context.Context) *StringCmd {
:= NewStringCmd(, "randomkey")
_ = (, )
return
}
func ( cmdable) ( context.Context, , string) *StatusCmd {
:= NewStatusCmd(, "rename", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, , string) *BoolCmd {
:= NewBoolCmd(, "renamenx", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, time.Duration, string) *StatusCmd {
:= NewStatusCmd(
,
"restore",
,
formatMs(, ),
,
)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, time.Duration, string) *StatusCmd {
:= NewStatusCmd(
,
"restore",
,
formatMs(, ),
,
"replace",
)
_ = (, )
return
}
type Sort struct {
By string
Offset, Count int64
Get []string
Order string
Alpha bool
}
func ( *Sort) ( string) []interface{} {
:= []interface{}{"sort", }
if .By != "" {
= append(, "by", .By)
}
if .Offset != 0 || .Count != 0 {
= append(, "limit", .Offset, .Count)
}
for , := range .Get {
= append(, "get", )
}
if .Order != "" {
= append(, .Order)
}
if .Alpha {
= append(, "alpha")
}
return
}
func ( cmdable) ( context.Context, string, *Sort) *StringSliceCmd {
:= NewStringSliceCmd(, .args()...)
_ = (, )
return
}
func ( cmdable) ( context.Context, , string, *Sort) *IntCmd {
:= .args()
if != "" {
= append(, "store", )
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, *Sort) *SliceCmd {
:= NewSliceCmd(, .args()...)
_ = (, )
return
}
func ( cmdable) ( context.Context, ...string) *IntCmd {
:= make([]interface{}, len()+1)
[0] = "touch"
for , := range {
[+1] =
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *DurationCmd {
:= NewDurationCmd(, time.Second, "ttl", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StatusCmd {
:= NewStatusCmd(, "type", )
_ = (, )
return
}
func ( cmdable) ( context.Context, , string) *IntCmd {
:= NewIntCmd(, "append", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *IntCmd {
:= NewIntCmd(, "decr", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, int64) *IntCmd {
:= NewIntCmd(, "decrby", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StringCmd {
:= NewStringCmd(, "get", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, , int64) *StringCmd {
:= NewStringCmd(, "getrange", , , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, interface{}) *StringCmd {
:= NewStringCmd(, "getset", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *IntCmd {
:= NewIntCmd(, "incr", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, int64) *IntCmd {
:= NewIntCmd(, "incrby", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, float64) *FloatCmd {
:= NewFloatCmd(, "incrbyfloat", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, ...string) *SliceCmd {
:= make([]interface{}, 1+len())
[0] = "mget"
for , := range {
[1+] =
}
:= NewSliceCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, ...interface{}) *StatusCmd {
:= make([]interface{}, 1, 1+len())
[0] = "mset"
= appendArgs(, )
:= NewStatusCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, ...interface{}) *BoolCmd {
:= make([]interface{}, 1, 1+len())
[0] = "msetnx"
= appendArgs(, )
:= NewBoolCmd(, ...)
_ = (, )
return
}
= NewBoolCmd(, "setnx", , )
} else {
if usePrecise() {
= NewBoolCmd(, "set", , , "px", formatMs(, ), "nx")
} else {
= NewBoolCmd(, "set", , , "ex", formatSec(, ), "nx")
}
}
_ = (, )
return
}
func ( cmdable) ( context.Context, string, interface{}, time.Duration) *BoolCmd {
var *BoolCmd
if == 0 {
= NewBoolCmd(, "set", , , "xx")
} else {
if usePrecise() {
= NewBoolCmd(, "set", , , "px", formatMs(, ), "xx")
} else {
= NewBoolCmd(, "set", , , "ex", formatSec(, ), "xx")
}
}
_ = (, )
return
}
func ( cmdable) ( context.Context, string, int64, string) *IntCmd {
:= NewIntCmd(, "setrange", , , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *IntCmd {
:= NewIntCmd(, "strlen", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, int64) *IntCmd {
:= NewIntCmd(, "getbit", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, int64, int) *IntCmd {
:= NewIntCmd(
,
"setbit",
,
,
,
)
_ = (, )
return
}
type BitCount struct {
Start, End int64
}
func ( cmdable) ( context.Context, string, *BitCount) *IntCmd {
:= []interface{}{"bitcount", }
if != nil {
= append(
,
.Start,
.End,
)
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, , string, ...string) *IntCmd {
:= make([]interface{}, 3+len())
[0] = "bitop"
[1] =
[2] =
for , := range {
[3+] =
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...string) *IntCmd {
return .bitOp(, "and", , ...)
}
func ( cmdable) ( context.Context, string, ...string) *IntCmd {
return .bitOp(, "or", , ...)
}
func ( cmdable) ( context.Context, string, ...string) *IntCmd {
return .bitOp(, "xor", , ...)
}
func ( cmdable) ( context.Context, string, string) *IntCmd {
return .bitOp(, "not", , )
}
func ( cmdable) ( context.Context, string, int64, ...int64) *IntCmd {
:= make([]interface{}, 3+len())
[0] = "bitpos"
[1] =
[2] =
switch len() {
case 0:
case 1:
[3] = [0]
case 2:
[3] = [0]
[4] = [1]
default:
panic("too many arguments")
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...interface{}) *IntSliceCmd {
:= make([]interface{}, 0, 2+len())
= append(, "bitfield")
= append(, )
= append(, ...)
:= NewIntSliceCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, uint64, string, int64) *ScanCmd {
:= []interface{}{"scan", }
if != "" {
= append(, "match", )
}
if > 0 {
= append(, "count", )
}
:= NewScanCmd(, , ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, uint64, string, int64) *ScanCmd {
:= []interface{}{"sscan", , }
if != "" {
= append(, "match", )
}
if > 0 {
= append(, "count", )
}
:= NewScanCmd(, , ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, uint64, string, int64) *ScanCmd {
:= []interface{}{"hscan", , }
if != "" {
= append(, "match", )
}
if > 0 {
= append(, "count", )
}
:= NewScanCmd(, , ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, uint64, string, int64) *ScanCmd {
:= []interface{}{"zscan", , }
if != "" {
= append(, "match", )
}
if > 0 {
= append(, "count", )
}
:= NewScanCmd(, , ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...string) *IntCmd {
:= make([]interface{}, 2+len())
[0] = "hdel"
[1] =
for , := range {
[2+] =
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, , string) *BoolCmd {
:= NewBoolCmd(, "hexists", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, , string) *StringCmd {
:= NewStringCmd(, "hget", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StringStringMapCmd {
:= NewStringStringMapCmd(, "hgetall", )
_ = (, )
return
}
func ( cmdable) ( context.Context, , string, int64) *IntCmd {
:= NewIntCmd(, "hincrby", , , )
_ = (, )
return
}
func ( cmdable) ( context.Context, , string, float64) *FloatCmd {
:= NewFloatCmd(, "hincrbyfloat", , , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StringSliceCmd {
:= NewStringSliceCmd(, "hkeys", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *IntCmd {
:= NewIntCmd(, "hlen", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...interface{}) *BoolCmd {
:= make([]interface{}, 2, 2+len())
[0] = "hmset"
[1] =
= appendArgs(, )
:= NewBoolCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, , string, interface{}) *BoolCmd {
:= NewBoolCmd(, "hsetnx", , , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StringSliceCmd {
:= NewStringSliceCmd(, "hvals", )
_ = (, )
return
}
func ( cmdable) ( context.Context, time.Duration, ...string) *StringSliceCmd {
:= make([]interface{}, 1+len()+1)
[0] = "blpop"
for , := range {
[1+] =
}
[len()-1] = formatSec(, )
:= NewStringSliceCmd(, ...)
.setReadTimeout()
_ = (, )
return
}
func ( cmdable) ( context.Context, time.Duration, ...string) *StringSliceCmd {
:= make([]interface{}, 1+len()+1)
[0] = "brpop"
for , := range {
[1+] =
}
[len()+1] = formatSec(, )
:= NewStringSliceCmd(, ...)
.setReadTimeout()
_ = (, )
return
}
func ( cmdable) ( context.Context, , string, time.Duration) *StringCmd {
:= NewStringCmd(
,
"brpoplpush",
,
,
formatSec(, ),
)
.setReadTimeout()
_ = (, )
return
}
func ( cmdable) ( context.Context, string, int64) *StringCmd {
:= NewStringCmd(, "lindex", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, , string, , interface{}) *IntCmd {
:= NewIntCmd(, "linsert", , , , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, , interface{}) *IntCmd {
:= NewIntCmd(, "linsert", , "before", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, , interface{}) *IntCmd {
:= NewIntCmd(, "linsert", , "after", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *IntCmd {
:= NewIntCmd(, "llen", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StringCmd {
:= NewStringCmd(, "lpop", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...interface{}) *IntCmd {
:= make([]interface{}, 2, 2+len())
[0] = "lpush"
[1] =
= appendArgs(, )
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...interface{}) *IntCmd {
:= make([]interface{}, 2, 2+len())
[0] = "lpushx"
[1] =
= appendArgs(, )
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, , int64) *StringSliceCmd {
:= NewStringSliceCmd(
,
"lrange",
,
,
,
)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, int64, interface{}) *IntCmd {
:= NewIntCmd(, "lrem", , , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, int64, interface{}) *StatusCmd {
:= NewStatusCmd(, "lset", , , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, , int64) *StatusCmd {
:= NewStatusCmd(
,
"ltrim",
,
,
,
)
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StringCmd {
:= NewStringCmd(, "rpop", )
_ = (, )
return
}
func ( cmdable) ( context.Context, , string) *StringCmd {
:= NewStringCmd(, "rpoplpush", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...interface{}) *IntCmd {
:= make([]interface{}, 2, 2+len())
[0] = "rpush"
[1] =
= appendArgs(, )
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...interface{}) *IntCmd {
:= make([]interface{}, 2, 2+len())
[0] = "rpushx"
[1] =
= appendArgs(, )
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...interface{}) *IntCmd {
:= make([]interface{}, 2, 2+len())
[0] = "sadd"
[1] =
= appendArgs(, )
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *IntCmd {
:= NewIntCmd(, "scard", )
_ = (, )
return
}
func ( cmdable) ( context.Context, ...string) *StringSliceCmd {
:= make([]interface{}, 1+len())
[0] = "sdiff"
for , := range {
[1+] =
}
:= NewStringSliceCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...string) *IntCmd {
:= make([]interface{}, 2+len())
[0] = "sdiffstore"
[1] =
for , := range {
[2+] =
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, ...string) *StringSliceCmd {
:= make([]interface{}, 1+len())
[0] = "sinter"
for , := range {
[1+] =
}
:= NewStringSliceCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...string) *IntCmd {
:= make([]interface{}, 2+len())
[0] = "sinterstore"
[1] =
for , := range {
[2+] =
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, interface{}) *BoolCmd {
:= NewBoolCmd(, "sismember", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StringSliceCmd {
:= NewStringSliceCmd(, "smembers", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StringStructMapCmd {
:= NewStringStructMapCmd(, "smembers", )
_ = (, )
return
}
func ( cmdable) ( context.Context, , string, interface{}) *BoolCmd {
:= NewBoolCmd(, "smove", , , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, int64) *StringSliceCmd {
:= NewStringSliceCmd(, "spop", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, int64) *StringSliceCmd {
:= NewStringSliceCmd(, "srandmember", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...interface{}) *IntCmd {
:= make([]interface{}, 2, 2+len())
[0] = "srem"
[1] =
= appendArgs(, )
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, ...string) *StringSliceCmd {
:= make([]interface{}, 1+len())
[0] = "sunion"
for , := range {
[1+] =
}
:= NewStringSliceCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...string) *IntCmd {
:= make([]interface{}, 2+len())
[0] = "sunionstore"
[1] =
for , := range {
[2+] =
}
:= NewIntCmd(, ...)
_ = (, )
return
}
type XAddArgs struct {
Stream string
MaxLen int64 // MAXLEN N
MaxLenApprox int64 // MAXLEN ~ N
ID string
Values interface{}
}
func ( cmdable) ( context.Context, *XAddArgs) *StringCmd {
:= make([]interface{}, 0, 8)
= append(, "xadd")
= append(, .Stream)
if .MaxLen > 0 {
= append(, "maxlen", .MaxLen)
} else if .MaxLenApprox > 0 {
= append(, "maxlen", "~", .MaxLenApprox)
}
if .ID != "" {
= append(, .ID)
} else {
= append(, "*")
}
= appendArg(, .Values)
:= NewStringCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...string) *IntCmd {
:= []interface{}{"xdel", }
for , := range {
= append(, )
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *IntCmd {
:= NewIntCmd(, "xlen", )
_ = (, )
return
}
func ( cmdable) ( context.Context, , , string) *XMessageSliceCmd {
:= NewXMessageSliceCmd(, "xrange", , , )
_ = (, )
return
}
func ( cmdable) ( context.Context, , , string, int64) *XMessageSliceCmd {
:= NewXMessageSliceCmd(, "xrange", , , , "count", )
_ = (, )
return
}
func ( cmdable) ( context.Context, , , string) *XMessageSliceCmd {
:= NewXMessageSliceCmd(, "xrevrange", , , )
_ = (, )
return
}
func ( cmdable) ( context.Context, , , string, int64) *XMessageSliceCmd {
:= NewXMessageSliceCmd(, "xrevrange", , , , "count", )
_ = (, )
return
}
type XReadArgs struct {
Streams []string // list of streams and ids, e.g. stream1 stream2 id1 id2
Count int64
Block time.Duration
}
func ( cmdable) ( context.Context, *XReadArgs) *XStreamSliceCmd {
:= make([]interface{}, 0, 5+len(.Streams))
= append(, "xread")
if .Count > 0 {
= append(, "count")
= append(, .Count)
}
if .Block >= 0 {
= append(, "block")
= append(, int64(.Block/time.Millisecond))
}
= append(, "streams")
for , := range .Streams {
= append(, )
}
:= NewXStreamSliceCmd(, ...)
if .Block >= 0 {
.setReadTimeout(.Block)
}
_ = (, )
return
}
func ( cmdable) ( context.Context, ...string) *XStreamSliceCmd {
return .XRead(, &XReadArgs{
Streams: ,
Block: -1,
})
}
func ( cmdable) ( context.Context, , , string) *StatusCmd {
:= NewStatusCmd(, "xgroup", "create", , , )
_ = (, )
return
}
func ( cmdable) ( context.Context, , , string) *StatusCmd {
:= NewStatusCmd(, "xgroup", "create", , , , "mkstream")
_ = (, )
return
}
func ( cmdable) ( context.Context, , , string) *StatusCmd {
:= NewStatusCmd(, "xgroup", "setid", , , )
_ = (, )
return
}
func ( cmdable) ( context.Context, , string) *IntCmd {
:= NewIntCmd(, "xgroup", "destroy", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, , , string) *IntCmd {
:= NewIntCmd(, "xgroup", "delconsumer", , , )
_ = (, )
return
}
type XReadGroupArgs struct {
Group string
Consumer string
Streams []string // list of streams and ids, e.g. stream1 stream2 id1 id2
Count int64
Block time.Duration
NoAck bool
}
func ( cmdable) ( context.Context, *XReadGroupArgs) *XStreamSliceCmd {
:= make([]interface{}, 0, 8+len(.Streams))
= append(, "xreadgroup", "group", .Group, .Consumer)
if .Count > 0 {
= append(, "count", .Count)
}
if .Block >= 0 {
= append(, "block", int64(.Block/time.Millisecond))
}
if .NoAck {
= append(, "noack")
}
= append(, "streams")
for , := range .Streams {
= append(, )
}
:= NewXStreamSliceCmd(, ...)
if .Block >= 0 {
.setReadTimeout(.Block)
}
_ = (, )
return
}
func ( cmdable) ( context.Context, , string, ...string) *IntCmd {
:= []interface{}{"xack", , }
for , := range {
= append(, )
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, , string) *XPendingCmd {
:= NewXPendingCmd(, "xpending", , )
_ = (, )
return
}
type XPendingExtArgs struct {
Stream string
Group string
Start string
End string
Count int64
Consumer string
}
func ( cmdable) ( context.Context, *XPendingExtArgs) *XPendingExtCmd {
:= make([]interface{}, 0, 7)
= append(, "xpending", .Stream, .Group, .Start, .End, .Count)
if .Consumer != "" {
= append(, .Consumer)
}
:= NewXPendingExtCmd(, ...)
_ = (, )
return
}
type XClaimArgs struct {
Stream string
Group string
Consumer string
MinIdle time.Duration
Messages []string
}
func ( cmdable) ( context.Context, *XClaimArgs) *XMessageSliceCmd {
:= xClaimArgs()
:= NewXMessageSliceCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, *XClaimArgs) *StringSliceCmd {
:= xClaimArgs()
= append(, "justid")
:= NewStringSliceCmd(, ...)
_ = (, )
return
}
func ( *XClaimArgs) []interface{} {
:= make([]interface{}, 0, 4+len(.Messages))
= append(,
"xclaim",
.Stream,
.Group, .Consumer,
int64(.MinIdle/time.Millisecond))
for , := range .Messages {
= append(, )
}
return
}
func ( cmdable) ( context.Context, string, int64) *IntCmd {
:= NewIntCmd(, "xtrim", , "maxlen", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, int64) *IntCmd {
:= NewIntCmd(, "xtrim", , "maxlen", "~", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *XInfoGroupsCmd {
:= NewXInfoGroupsCmd(, )
_ = (, )
return
}
func ( cmdable) ( context.Context, time.Duration, ...string) *ZWithKeyCmd {
:= make([]interface{}, 1+len()+1)
[0] = "bzpopmax"
for , := range {
[1+] =
}
[len()-1] = formatSec(, )
:= NewZWithKeyCmd(, ...)
.setReadTimeout()
_ = (, )
return
}
func ( cmdable) ( context.Context, time.Duration, ...string) *ZWithKeyCmd {
:= make([]interface{}, 1+len()+1)
[0] = "bzpopmin"
for , := range {
[1+] =
}
[len()-1] = formatSec(, )
:= NewZWithKeyCmd(, ...)
.setReadTimeout()
_ = (, )
return
}
func ( cmdable) ( context.Context, []interface{}, int, ...*Z) *IntCmd {
for , := range {
[+2*] = .Score
[+2*+1] = .Member
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...*Z) *IntCmd {
const = 4
:= make([]interface{}, +2*len())
[0], [1], [2], [3] = "zadd", , "xx", "ch"
return .zAdd(, , , ...)
}
func ( cmdable) ( context.Context, []interface{}, int, ...*Z) *FloatCmd {
for , := range {
[+2*] = .Score
[+2*+1] = .Member
}
:= NewFloatCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, *Z) *FloatCmd {
const = 4
:= make([]interface{}, +2)
[0], [1], [2], [3] = "zadd", , "incr", "xx"
return .zIncr(, , , )
}
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{}, 3+len(.Keys))
[0] = "zinterstore"
[1] =
[2] = len(.Keys)
for , := range .Keys {
[3+] =
}
if len(.Weights) > 0 {
= append(, "weights")
for , := range .Weights {
= append(, )
}
}
if .Aggregate != "" {
= append(, "aggregate", .Aggregate)
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...int64) *ZSliceCmd {
:= []interface{}{
"zpopmax",
,
}
switch len() {
case 0:
break
case 1:
= append(, [0])
default:
panic("too many arguments")
}
:= NewZSliceCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...int64) *ZSliceCmd {
:= []interface{}{
"zpopmin",
,
}
switch len() {
case 0:
break
case 1:
= append(, [0])
default:
panic("too many arguments")
}
:= NewZSliceCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, , int64, bool) *StringSliceCmd {
:= []interface{}{
"zrange",
,
,
,
}
if {
= append(, "withscores")
}
:= NewStringSliceCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, , int64) *StringSliceCmd {
return .zRange(, , , , false)
}
func ( cmdable) ( context.Context, string, , int64) *ZSliceCmd {
:= NewZSliceCmd(, "zrange", , , , "withscores")
_ = (, )
return
}
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
}
func ( cmdable) ( context.Context, string, *ZRangeBy) *StringSliceCmd {
return .zRangeBy(, "zrangebyscore", , , false)
}
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) *IntCmd {
:= NewIntCmd(, "zrank", , )
_ = (, )
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
}
func ( cmdable) ( context.Context, string, , int64) *StringSliceCmd {
:= NewStringSliceCmd(, "zrevrange", , , )
_ = (, )
return
}
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
}
func ( cmdable) ( context.Context, string, *ZRangeBy) *StringSliceCmd {
return .zRevRangeBy(, "zrevrangebyscore", , )
}
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) *FloatCmd {
:= NewFloatCmd(, "zscore", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, *ZStore) *IntCmd {
:= make([]interface{}, 3+len(.Keys))
[0] = "zunionstore"
[1] =
[2] = len(.Keys)
for , := range .Keys {
[3+] =
}
if len(.Weights) > 0 {
= append(, "weights")
for , := range .Weights {
= append(, )
}
}
if .Aggregate != "" {
= append(, "aggregate", .Aggregate)
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...interface{}) *IntCmd {
:= make([]interface{}, 2, 2+len())
[0] = "pfadd"
[1] =
= appendArgs(, )
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, ...string) *IntCmd {
:= make([]interface{}, 1+len())
[0] = "pfcount"
for , := range {
[1+] =
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...string) *StatusCmd {
:= make([]interface{}, 2+len())
[0] = "pfmerge"
[1] =
for , := range {
[2+] =
}
:= NewStatusCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "bgrewriteaof")
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "bgsave")
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StatusCmd {
:= NewStatusCmd(, "client", "kill", )
_ = (, )
return
}
func ( cmdable) ( context.Context, ...string) *IntCmd {
:= make([]interface{}, 2+len())
[0] = "client"
[1] = "kill"
for , := range {
[2+] =
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context) *StringCmd {
:= NewStringCmd(, "client", "list")
_ = (, )
return
}
func ( cmdable) ( context.Context, time.Duration) *BoolCmd {
:= NewBoolCmd(, "client", "pause", formatMs(, ))
_ = (, )
return
}
func ( cmdable) ( context.Context) *IntCmd {
:= NewIntCmd(, "client", "id")
_ = (, )
return
}
func ( cmdable) ( context.Context, int64) *IntCmd {
:= NewIntCmd(, "client", "unblock", )
_ = (, )
return
}
func ( cmdable) ( context.Context, int64) *IntCmd {
:= NewIntCmd(, "client", "unblock", , "error")
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *SliceCmd {
:= NewSliceCmd(, "config", "get", )
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "config", "resetstat")
_ = (, )
return
}
func ( cmdable) ( context.Context, , string) *StatusCmd {
:= NewStatusCmd(, "config", "set", , )
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "config", "rewrite")
_ = (, )
return
}
func ( cmdable) ( context.Context) *IntCmd {
:= NewIntCmd(, "dbsize")
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "flushall")
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "flushall", "async")
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "flushdb")
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "flushdb", "async")
_ = (, )
return
}
func ( cmdable) ( context.Context, ...string) *StringCmd {
:= []interface{}{"info"}
if len() > 0 {
= append(, [0])
}
:= NewStringCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context) *IntCmd {
:= NewIntCmd(, "lastsave")
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "save")
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StatusCmd {
var []interface{}
if == "" {
= []interface{}{"shutdown"}
} else {
= []interface{}{"shutdown", }
}
:= NewStatusCmd(, ...)
_ = (, )
if := .Err(); != nil {
.err = errors.New(.val)
.val = ""
}
return
}
func ( cmdable) ( context.Context) *StatusCmd {
return .shutdown(, "")
}
func ( cmdable) ( context.Context) *StatusCmd {
return .shutdown(, "save")
}
func ( cmdable) ( context.Context) *StatusCmd {
return .shutdown(, "nosave")
}
func ( cmdable) ( context.Context, , string) *StatusCmd {
:= NewStatusCmd(, "slaveof", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, int64) *SlowLogCmd {
:= NewSlowLogCmd(context.Background(), "slowlog", "get", )
_ = (, )
return
}
func ( cmdable) ( context.Context) {
panic("not implemented")
}
func ( cmdable) ( context.Context) *TimeCmd {
:= NewTimeCmd(, "time")
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StringCmd {
:= NewStringCmd(, "debug", "object", )
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "readonly")
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "readwrite")
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...int) *IntCmd {
:= []interface{}{"memory", "usage", }
if len() > 0 {
if len() != 1 {
panic("MemoryUsage expects single sample count")
}
= append(, "SAMPLES", [0])
}
:= NewIntCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, []string, ...interface{}) *Cmd {
:= make([]interface{}, 3+len(), 3+len()+len())
[0] = "eval"
[1] =
[2] = len()
for , := range {
[3+] =
}
= appendArgs(, )
:= NewCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, []string, ...interface{}) *Cmd {
:= make([]interface{}, 3+len(), 3+len()+len())
[0] = "evalsha"
[1] =
[2] = len()
for , := range {
[3+] =
}
= appendArgs(, )
:= NewCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, ...string) *BoolSliceCmd {
:= make([]interface{}, 2+len())
[0] = "script"
[1] = "exists"
for , := range {
[2+] =
}
:= NewBoolSliceCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "script", "flush")
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "script", "kill")
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StringCmd {
:= NewStringCmd(, "script", "load", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, interface{}) *IntCmd {
:= NewIntCmd(, "publish", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StringSliceCmd {
:= []interface{}{"pubsub", "channels"}
if != "*" {
= append(, )
}
:= NewStringSliceCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, ...string) *StringIntMapCmd {
:= make([]interface{}, 2+len())
[0] = "pubsub"
[1] = "numsub"
for , := range {
[2+] =
}
:= NewStringIntMapCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context) *IntCmd {
:= NewIntCmd(, "pubsub", "numpat")
_ = (, )
return
}
func ( cmdable) ( context.Context) *ClusterSlotsCmd {
:= NewClusterSlotsCmd(, "cluster", "slots")
_ = (, )
return
}
func ( cmdable) ( context.Context) *StringCmd {
:= NewStringCmd(, "cluster", "nodes")
_ = (, )
return
}
func ( cmdable) ( context.Context, , string) *StatusCmd {
:= NewStatusCmd(, "cluster", "meet", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StatusCmd {
:= NewStatusCmd(, "cluster", "forget", )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StatusCmd {
:= NewStatusCmd(, "cluster", "replicate", )
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "cluster", "reset", "soft")
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "cluster", "reset", "hard")
_ = (, )
return
}
func ( cmdable) ( context.Context) *StringCmd {
:= NewStringCmd(, "cluster", "info")
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *IntCmd {
:= NewIntCmd(, "cluster", "keyslot", )
_ = (, )
return
}
func ( cmdable) ( context.Context, int, int) *StringSliceCmd {
:= NewStringSliceCmd(, "cluster", "getkeysinslot", , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *IntCmd {
:= NewIntCmd(, "cluster", "count-failure-reports", )
_ = (, )
return
}
func ( cmdable) ( context.Context, int) *IntCmd {
:= NewIntCmd(, "cluster", "countkeysinslot", )
_ = (, )
return
}
func ( cmdable) ( context.Context, ...int) *StatusCmd {
:= make([]interface{}, 2+len())
[0] = "cluster"
[1] = "delslots"
for , := range {
[2+] =
}
:= NewStatusCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, , int) *StatusCmd {
:= - + 1
:= make([]int, )
for := 0; < ; ++ {
[] = +
}
return .ClusterDelSlots(, ...)
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "cluster", "saveconfig")
_ = (, )
return
}
func ( cmdable) ( context.Context, string) *StringSliceCmd {
:= NewStringSliceCmd(, "cluster", "slaves", )
_ = (, )
return
}
func ( cmdable) ( context.Context) *StatusCmd {
:= NewStatusCmd(, "cluster", "failover")
_ = (, )
return
}
func ( cmdable) ( context.Context, ...int) *StatusCmd {
:= make([]interface{}, 2+len())
[0] = "cluster"
[1] = "addslots"
for , := range {
[2+] =
}
:= NewStatusCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, , int) *StatusCmd {
:= - + 1
:= make([]int, )
for := 0; < ; ++ {
[] = +
}
return .ClusterAddSlots(, ...)
}
func ( cmdable) (
context.Context, string, , float64, *GeoRadiusQuery,
) *GeoLocationCmd {
:= NewGeoLocationCmd(, , "georadius_ro", , , )
if .Store != "" || .StoreDist != "" {
.SetErr(errors.New("GeoRadius does not support Store or StoreDist"))
return
}
_ = (, )
return
}
func ( cmdable) (
context.Context, , string, *GeoRadiusQuery,
) *GeoLocationCmd {
:= NewGeoLocationCmd(, , "georadiusbymember_ro", , )
if .Store != "" || .StoreDist != "" {
.SetErr(errors.New("GeoRadiusByMember does not support Store or StoreDist"))
return
}
_ = (, )
return
}
func ( cmdable) (
context.Context, , string, *GeoRadiusQuery,
) *IntCmd {
:= geoLocationArgs(, "georadiusbymember", , )
:= NewIntCmd(, ...)
if .Store == "" && .StoreDist == "" {
.SetErr(errors.New("GeoRadiusByMemberStore requires Store or StoreDist"))
return
}
_ = (, )
return
}
func ( cmdable) (
context.Context, string, , , string,
) *FloatCmd {
if == "" {
= "km"
}
:= NewFloatCmd(, "geodist", , , , )
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...string) *StringSliceCmd {
:= make([]interface{}, 2+len())
[0] = "geohash"
[1] =
for , := range {
[2+] =
}
:= NewStringSliceCmd(, ...)
_ = (, )
return
}
func ( cmdable) ( context.Context, string, ...string) *GeoPosCmd {
:= make([]interface{}, 2+len())
[0] = "geopos"
[1] =
for , := range {
[2+] =
}
:= NewGeoPosCmd(, ...)
_ = (, )
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |