From 72a6069cc507c0722e44a6388fa8fcb526ad268e Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Wed, 25 Jun 2014 10:40:56 +0300 Subject: [PATCH] Rename req to cmd. --- commands.go | 860 ++++++++++++++++++++++++++-------------------------- 1 file changed, 430 insertions(+), 430 deletions(-) diff --git a/commands.go b/commands.go index c94adc11..8272bb89 100644 --- a/commands.go +++ b/commands.go @@ -19,21 +19,21 @@ func readTimeout(sec int64) time.Duration { //------------------------------------------------------------------------------ func (c *Client) Auth(password string) *StatusCmd { - req := NewStatusCmd("AUTH", password) - c.Process(req) - return req + cmd := NewStatusCmd("AUTH", password) + c.Process(cmd) + return cmd } func (c *Client) Echo(message string) *StringCmd { - req := NewStringCmd("ECHO", message) - c.Process(req) - return req + cmd := NewStringCmd("ECHO", message) + c.Process(cmd) + return cmd } func (c *Client) Ping() *StatusCmd { - req := NewStatusCmd("PING") - c.Process(req) - return req + cmd := NewStatusCmd("PING") + c.Process(cmd) + return cmd } func (c *Client) Quit() *StatusCmd { @@ -41,52 +41,52 @@ func (c *Client) Quit() *StatusCmd { } func (c *Client) Select(index int64) *StatusCmd { - req := NewStatusCmd("SELECT", strconv.FormatInt(index, 10)) - c.Process(req) - return req + cmd := NewStatusCmd("SELECT", strconv.FormatInt(index, 10)) + c.Process(cmd) + return cmd } //------------------------------------------------------------------------------ func (c *Client) Del(keys ...string) *IntCmd { args := append([]string{"DEL"}, keys...) - req := NewIntCmd(args...) - c.Process(req) - return req + cmd := NewIntCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) Dump(key string) *StringCmd { - req := NewStringCmd("DUMP", key) - c.Process(req) - return req + cmd := NewStringCmd("DUMP", key) + c.Process(cmd) + return cmd } func (c *Client) Exists(key string) *BoolCmd { - req := NewBoolCmd("EXISTS", key) - c.Process(req) - return req + cmd := NewBoolCmd("EXISTS", key) + c.Process(cmd) + return cmd } func (c *Client) Expire(key string, dur time.Duration) *BoolCmd { - req := NewBoolCmd("EXPIRE", key, strconv.FormatInt(int64(dur/time.Second), 10)) - c.Process(req) - return req + cmd := NewBoolCmd("EXPIRE", key, strconv.FormatInt(int64(dur/time.Second), 10)) + c.Process(cmd) + return cmd } func (c *Client) ExpireAt(key string, tm time.Time) *BoolCmd { - req := NewBoolCmd("EXPIREAT", key, strconv.FormatInt(tm.Unix(), 10)) - c.Process(req) - return req + cmd := NewBoolCmd("EXPIREAT", key, strconv.FormatInt(tm.Unix(), 10)) + c.Process(cmd) + return cmd } func (c *Client) Keys(pattern string) *StringSliceCmd { - req := NewStringSliceCmd("KEYS", pattern) - c.Process(req) - return req + cmd := NewStringSliceCmd("KEYS", pattern) + c.Process(cmd) + return cmd } func (c *Client) Migrate(host, port, key string, db, timeout int64) *StatusCmd { - req := NewStatusCmd( + cmd := NewStatusCmd( "MIGRATE", host, port, @@ -94,93 +94,93 @@ func (c *Client) Migrate(host, port, key string, db, timeout int64) *StatusCmd { strconv.FormatInt(db, 10), strconv.FormatInt(timeout, 10), ) - req.setReadTimeout(readTimeout(timeout)) - c.Process(req) - return req + cmd.setReadTimeout(readTimeout(timeout)) + c.Process(cmd) + return cmd } func (c *Client) Move(key string, db int64) *BoolCmd { - req := NewBoolCmd("MOVE", key, strconv.FormatInt(db, 10)) - c.Process(req) - return req + cmd := NewBoolCmd("MOVE", key, strconv.FormatInt(db, 10)) + c.Process(cmd) + return cmd } func (c *Client) ObjectRefCount(keys ...string) *IntCmd { args := append([]string{"OBJECT", "REFCOUNT"}, keys...) - req := NewIntCmd(args...) - c.Process(req) - return req + cmd := NewIntCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) ObjectEncoding(keys ...string) *StringCmd { args := append([]string{"OBJECT", "ENCODING"}, keys...) - req := NewStringCmd(args...) - c.Process(req) - return req + cmd := NewStringCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) ObjectIdleTime(keys ...string) *DurationCmd { args := append([]string{"OBJECT", "IDLETIME"}, keys...) - req := NewDurationCmd(time.Second, args...) - c.Process(req) - return req + cmd := NewDurationCmd(time.Second, args...) + c.Process(cmd) + return cmd } func (c *Client) Persist(key string) *BoolCmd { - req := NewBoolCmd("PERSIST", key) - c.Process(req) - return req + cmd := NewBoolCmd("PERSIST", key) + c.Process(cmd) + return cmd } func (c *Client) PExpire(key string, dur time.Duration) *BoolCmd { - req := NewBoolCmd("PEXPIRE", key, strconv.FormatInt(int64(dur/time.Millisecond), 10)) - c.Process(req) - return req + cmd := NewBoolCmd("PEXPIRE", key, strconv.FormatInt(int64(dur/time.Millisecond), 10)) + c.Process(cmd) + return cmd } func (c *Client) PExpireAt(key string, tm time.Time) *BoolCmd { - req := NewBoolCmd( + cmd := NewBoolCmd( "PEXPIREAT", key, strconv.FormatInt(tm.UnixNano()/int64(time.Millisecond), 10), ) - c.Process(req) - return req + c.Process(cmd) + return cmd } func (c *Client) PTTL(key string) *DurationCmd { - req := NewDurationCmd(time.Millisecond, "PTTL", key) - c.Process(req) - return req + cmd := NewDurationCmd(time.Millisecond, "PTTL", key) + c.Process(cmd) + return cmd } func (c *Client) RandomKey() *StringCmd { - req := NewStringCmd("RANDOMKEY") - c.Process(req) - return req + cmd := NewStringCmd("RANDOMKEY") + c.Process(cmd) + return cmd } func (c *Client) Rename(key, newkey string) *StatusCmd { - req := NewStatusCmd("RENAME", key, newkey) - c.Process(req) - return req + cmd := NewStatusCmd("RENAME", key, newkey) + c.Process(cmd) + return cmd } func (c *Client) RenameNX(key, newkey string) *BoolCmd { - req := NewBoolCmd("RENAMENX", key, newkey) - c.Process(req) - return req + cmd := NewBoolCmd("RENAMENX", key, newkey) + c.Process(cmd) + return cmd } func (c *Client) Restore(key string, ttl int64, value string) *StatusCmd { - req := NewStatusCmd( + cmd := NewStatusCmd( "RESTORE", key, strconv.FormatInt(ttl, 10), value, ) - c.Process(req) - return req + c.Process(cmd) + return cmd } type Sort struct { @@ -212,21 +212,21 @@ func (c *Client) Sort(key string, sort Sort) *StringSliceCmd { if sort.Store != "" { args = append(args, "STORE", sort.Store) } - req := NewStringSliceCmd(args...) - c.Process(req) - return req + cmd := NewStringSliceCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) TTL(key string) *DurationCmd { - req := NewDurationCmd(time.Second, "TTL", key) - c.Process(req) - return req + cmd := NewDurationCmd(time.Second, "TTL", key) + c.Process(cmd) + return cmd } func (c *Client) Type(key string) *StatusCmd { - req := NewStatusCmd("TYPE", key) - c.Process(req) - return req + cmd := NewStatusCmd("TYPE", key) + c.Process(cmd) + return cmd } func (c *Client) Scan(cursor int64, match string, count int64) *ScanCmd { @@ -237,9 +237,9 @@ func (c *Client) Scan(cursor int64, match string, count int64) *ScanCmd { if count > 0 { args = append(args, "COUNT", strconv.FormatInt(count, 10)) } - req := NewScanCmd(args...) - c.Process(req) - return req + cmd := NewScanCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) SScan(key string, cursor int64, match string, count int64) *ScanCmd { @@ -250,9 +250,9 @@ func (c *Client) SScan(key string, cursor int64, match string, count int64) *Sca if count > 0 { args = append(args, "COUNT", strconv.FormatInt(count, 10)) } - req := NewScanCmd(args...) - c.Process(req) - return req + cmd := NewScanCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) HScan(key string, cursor int64, match string, count int64) *ScanCmd { @@ -263,9 +263,9 @@ func (c *Client) HScan(key string, cursor int64, match string, count int64) *Sca if count > 0 { args = append(args, "COUNT", strconv.FormatInt(count, 10)) } - req := NewScanCmd(args...) - c.Process(req) - return req + cmd := NewScanCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) ZScan(key string, cursor int64, match string, count int64) *ScanCmd { @@ -276,17 +276,17 @@ func (c *Client) ZScan(key string, cursor int64, match string, count int64) *Sca if count > 0 { args = append(args, "COUNT", strconv.FormatInt(count, 10)) } - req := NewScanCmd(args...) - c.Process(req) - return req + cmd := NewScanCmd(args...) + c.Process(cmd) + return cmd } //------------------------------------------------------------------------------ func (c *Client) Append(key, value string) *IntCmd { - req := NewIntCmd("APPEND", key, value) - c.Process(req) - return req + cmd := NewIntCmd("APPEND", key, value) + c.Process(cmd) + return cmd } type BitCount struct { @@ -302,17 +302,17 @@ func (c *Client) BitCount(key string, bitCount *BitCount) *IntCmd { strconv.FormatInt(bitCount.End, 10), ) } - req := NewIntCmd(args...) - c.Process(req) - return req + cmd := NewIntCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) bitOp(op, destKey string, keys ...string) *IntCmd { args := []string{"BITOP", op, destKey} args = append(args, keys...) - req := NewIntCmd(args...) - c.Process(req) - return req + cmd := NewIntCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) BitOpAnd(destKey string, keys ...string) *IntCmd { @@ -332,224 +332,224 @@ func (c *Client) BitOpNot(destKey string, key string) *IntCmd { } func (c *Client) Decr(key string) *IntCmd { - req := NewIntCmd("DECR", key) - c.Process(req) - return req + cmd := NewIntCmd("DECR", key) + c.Process(cmd) + return cmd } func (c *Client) DecrBy(key string, decrement int64) *IntCmd { - req := NewIntCmd("DECRBY", key, strconv.FormatInt(decrement, 10)) - c.Process(req) - return req + cmd := NewIntCmd("DECRBY", key, strconv.FormatInt(decrement, 10)) + c.Process(cmd) + return cmd } func (c *Client) Get(key string) *StringCmd { - req := NewStringCmd("GET", key) - c.Process(req) - return req + cmd := NewStringCmd("GET", key) + c.Process(cmd) + return cmd } func (c *Client) GetBit(key string, offset int64) *IntCmd { - req := NewIntCmd("GETBIT", key, strconv.FormatInt(offset, 10)) - c.Process(req) - return req + cmd := NewIntCmd("GETBIT", key, strconv.FormatInt(offset, 10)) + c.Process(cmd) + return cmd } func (c *Client) GetRange(key string, start, end int64) *StringCmd { - req := NewStringCmd( + cmd := NewStringCmd( "GETRANGE", key, strconv.FormatInt(start, 10), strconv.FormatInt(end, 10), ) - c.Process(req) - return req + c.Process(cmd) + return cmd } func (c *Client) GetSet(key, value string) *StringCmd { - req := NewStringCmd("GETSET", key, value) - c.Process(req) - return req + cmd := NewStringCmd("GETSET", key, value) + c.Process(cmd) + return cmd } func (c *Client) Incr(key string) *IntCmd { - req := NewIntCmd("INCR", key) - c.Process(req) - return req + cmd := NewIntCmd("INCR", key) + c.Process(cmd) + return cmd } func (c *Client) IncrBy(key string, value int64) *IntCmd { - req := NewIntCmd("INCRBY", key, strconv.FormatInt(value, 10)) - c.Process(req) - return req + cmd := NewIntCmd("INCRBY", key, strconv.FormatInt(value, 10)) + c.Process(cmd) + return cmd } func (c *Client) IncrByFloat(key string, value float64) *FloatCmd { - req := NewFloatCmd("INCRBYFLOAT", key, formatFloat(value)) - c.Process(req) - return req + cmd := NewFloatCmd("INCRBYFLOAT", key, formatFloat(value)) + c.Process(cmd) + return cmd } func (c *Client) MGet(keys ...string) *SliceCmd { args := append([]string{"MGET"}, keys...) - req := NewSliceCmd(args...) - c.Process(req) - return req + cmd := NewSliceCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) MSet(pairs ...string) *StatusCmd { args := append([]string{"MSET"}, pairs...) - req := NewStatusCmd(args...) - c.Process(req) - return req + cmd := NewStatusCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) MSetNX(pairs ...string) *BoolCmd { args := append([]string{"MSETNX"}, pairs...) - req := NewBoolCmd(args...) - c.Process(req) - return req + cmd := NewBoolCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) PSetEx(key string, dur time.Duration, value string) *StatusCmd { - req := NewStatusCmd( + cmd := NewStatusCmd( "PSETEX", key, strconv.FormatInt(int64(dur/time.Millisecond), 10), value, ) - c.Process(req) - return req + c.Process(cmd) + return cmd } func (c *Client) Set(key, value string) *StatusCmd { - req := NewStatusCmd("SET", key, value) - c.Process(req) - return req + cmd := NewStatusCmd("SET", key, value) + c.Process(cmd) + return cmd } func (c *Client) SetBit(key string, offset int64, value int) *IntCmd { - req := NewIntCmd( + cmd := NewIntCmd( "SETBIT", key, strconv.FormatInt(offset, 10), strconv.FormatInt(int64(value), 10), ) - c.Process(req) - return req + c.Process(cmd) + return cmd } func (c *Client) SetEx(key string, dur time.Duration, value string) *StatusCmd { - req := NewStatusCmd("SETEX", key, strconv.FormatInt(int64(dur/time.Second), 10), value) - c.Process(req) - return req + cmd := NewStatusCmd("SETEX", key, strconv.FormatInt(int64(dur/time.Second), 10), value) + c.Process(cmd) + return cmd } func (c *Client) SetNX(key, value string) *BoolCmd { - req := NewBoolCmd("SETNX", key, value) - c.Process(req) - return req + cmd := NewBoolCmd("SETNX", key, value) + c.Process(cmd) + return cmd } func (c *Client) SetRange(key string, offset int64, value string) *IntCmd { - req := NewIntCmd("SETRANGE", key, strconv.FormatInt(offset, 10), value) - c.Process(req) - return req + cmd := NewIntCmd("SETRANGE", key, strconv.FormatInt(offset, 10), value) + c.Process(cmd) + return cmd } func (c *Client) StrLen(key string) *IntCmd { - req := NewIntCmd("STRLEN", key) - c.Process(req) - return req + cmd := NewIntCmd("STRLEN", key) + c.Process(cmd) + return cmd } //------------------------------------------------------------------------------ func (c *Client) HDel(key string, fields ...string) *IntCmd { args := append([]string{"HDEL", key}, fields...) - req := NewIntCmd(args...) - c.Process(req) - return req + cmd := NewIntCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) HExists(key, field string) *BoolCmd { - req := NewBoolCmd("HEXISTS", key, field) - c.Process(req) - return req + cmd := NewBoolCmd("HEXISTS", key, field) + c.Process(cmd) + return cmd } func (c *Client) HGet(key, field string) *StringCmd { - req := NewStringCmd("HGET", key, field) - c.Process(req) - return req + cmd := NewStringCmd("HGET", key, field) + c.Process(cmd) + return cmd } func (c *Client) HGetAll(key string) *StringSliceCmd { - req := NewStringSliceCmd("HGETALL", key) - c.Process(req) - return req + cmd := NewStringSliceCmd("HGETALL", key) + c.Process(cmd) + return cmd } func (c *Client) HGetAllMap(key string) *StringStringMapCmd { - req := NewStringStringMapCmd("HGETALL", key) - c.Process(req) - return req + cmd := NewStringStringMapCmd("HGETALL", key) + c.Process(cmd) + return cmd } func (c *Client) HIncrBy(key, field string, incr int64) *IntCmd { - req := NewIntCmd("HINCRBY", key, field, strconv.FormatInt(incr, 10)) - c.Process(req) - return req + cmd := NewIntCmd("HINCRBY", key, field, strconv.FormatInt(incr, 10)) + c.Process(cmd) + return cmd } func (c *Client) HIncrByFloat(key, field string, incr float64) *FloatCmd { - req := NewFloatCmd("HINCRBYFLOAT", key, field, formatFloat(incr)) - c.Process(req) - return req + cmd := NewFloatCmd("HINCRBYFLOAT", key, field, formatFloat(incr)) + c.Process(cmd) + return cmd } func (c *Client) HKeys(key string) *StringSliceCmd { - req := NewStringSliceCmd("HKEYS", key) - c.Process(req) - return req + cmd := NewStringSliceCmd("HKEYS", key) + c.Process(cmd) + return cmd } func (c *Client) HLen(key string) *IntCmd { - req := NewIntCmd("HLEN", key) - c.Process(req) - return req + cmd := NewIntCmd("HLEN", key) + c.Process(cmd) + return cmd } func (c *Client) HMGet(key string, fields ...string) *SliceCmd { args := append([]string{"HMGET", key}, fields...) - req := NewSliceCmd(args...) - c.Process(req) - return req + cmd := NewSliceCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) HMSet(key, field, value string, pairs ...string) *StatusCmd { args := append([]string{"HMSET", key, field, value}, pairs...) - req := NewStatusCmd(args...) - c.Process(req) - return req + cmd := NewStatusCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) HSet(key, field, value string) *BoolCmd { - req := NewBoolCmd("HSET", key, field, value) - c.Process(req) - return req + cmd := NewBoolCmd("HSET", key, field, value) + c.Process(cmd) + return cmd } func (c *Client) HSetNX(key, field, value string) *BoolCmd { - req := NewBoolCmd("HSETNX", key, field, value) - c.Process(req) - return req + cmd := NewBoolCmd("HSETNX", key, field, value) + c.Process(cmd) + return cmd } func (c *Client) HVals(key string) *StringSliceCmd { - req := NewStringSliceCmd("HVALS", key) - c.Process(req) - return req + cmd := NewStringSliceCmd("HVALS", key) + c.Process(cmd) + return cmd } //------------------------------------------------------------------------------ @@ -557,221 +557,221 @@ func (c *Client) HVals(key string) *StringSliceCmd { func (c *Client) BLPop(timeout int64, keys ...string) *StringSliceCmd { args := append([]string{"BLPOP"}, keys...) args = append(args, strconv.FormatInt(timeout, 10)) - req := NewStringSliceCmd(args...) - req.setReadTimeout(readTimeout(timeout)) - c.Process(req) - return req + cmd := NewStringSliceCmd(args...) + cmd.setReadTimeout(readTimeout(timeout)) + c.Process(cmd) + return cmd } func (c *Client) BRPop(timeout int64, keys ...string) *StringSliceCmd { args := append([]string{"BRPOP"}, keys...) args = append(args, strconv.FormatInt(timeout, 10)) - req := NewStringSliceCmd(args...) - req.setReadTimeout(readTimeout(timeout)) - c.Process(req) - return req + cmd := NewStringSliceCmd(args...) + cmd.setReadTimeout(readTimeout(timeout)) + c.Process(cmd) + return cmd } func (c *Client) BRPopLPush(source, destination string, timeout int64) *StringCmd { - req := NewStringCmd( + cmd := NewStringCmd( "BRPOPLPUSH", source, destination, strconv.FormatInt(timeout, 10), ) - req.setReadTimeout(readTimeout(timeout)) - c.Process(req) - return req + cmd.setReadTimeout(readTimeout(timeout)) + c.Process(cmd) + return cmd } func (c *Client) LIndex(key string, index int64) *StringCmd { - req := NewStringCmd("LINDEX", key, strconv.FormatInt(index, 10)) - c.Process(req) - return req + cmd := NewStringCmd("LINDEX", key, strconv.FormatInt(index, 10)) + c.Process(cmd) + return cmd } func (c *Client) LInsert(key, op, pivot, value string) *IntCmd { - req := NewIntCmd("LINSERT", key, op, pivot, value) - c.Process(req) - return req + cmd := NewIntCmd("LINSERT", key, op, pivot, value) + c.Process(cmd) + return cmd } func (c *Client) LLen(key string) *IntCmd { - req := NewIntCmd("LLEN", key) - c.Process(req) - return req + cmd := NewIntCmd("LLEN", key) + c.Process(cmd) + return cmd } func (c *Client) LPop(key string) *StringCmd { - req := NewStringCmd("LPOP", key) - c.Process(req) - return req + cmd := NewStringCmd("LPOP", key) + c.Process(cmd) + return cmd } func (c *Client) LPush(key string, values ...string) *IntCmd { args := append([]string{"LPUSH", key}, values...) - req := NewIntCmd(args...) - c.Process(req) - return req + cmd := NewIntCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) LPushX(key, value string) *IntCmd { - req := NewIntCmd("LPUSHX", key, value) - c.Process(req) - return req + cmd := NewIntCmd("LPUSHX", key, value) + c.Process(cmd) + return cmd } func (c *Client) LRange(key string, start, stop int64) *StringSliceCmd { - req := NewStringSliceCmd( + cmd := NewStringSliceCmd( "LRANGE", key, strconv.FormatInt(start, 10), strconv.FormatInt(stop, 10), ) - c.Process(req) - return req + c.Process(cmd) + return cmd } func (c *Client) LRem(key string, count int64, value string) *IntCmd { - req := NewIntCmd("LREM", key, strconv.FormatInt(count, 10), value) - c.Process(req) - return req + cmd := NewIntCmd("LREM", key, strconv.FormatInt(count, 10), value) + c.Process(cmd) + return cmd } func (c *Client) LSet(key string, index int64, value string) *StatusCmd { - req := NewStatusCmd("LSET", key, strconv.FormatInt(index, 10), value) - c.Process(req) - return req + cmd := NewStatusCmd("LSET", key, strconv.FormatInt(index, 10), value) + c.Process(cmd) + return cmd } func (c *Client) LTrim(key string, start, stop int64) *StatusCmd { - req := NewStatusCmd( + cmd := NewStatusCmd( "LTRIM", key, strconv.FormatInt(start, 10), strconv.FormatInt(stop, 10), ) - c.Process(req) - return req + c.Process(cmd) + return cmd } func (c *Client) RPop(key string) *StringCmd { - req := NewStringCmd("RPOP", key) - c.Process(req) - return req + cmd := NewStringCmd("RPOP", key) + c.Process(cmd) + return cmd } func (c *Client) RPopLPush(source, destination string) *StringCmd { - req := NewStringCmd("RPOPLPUSH", source, destination) - c.Process(req) - return req + cmd := NewStringCmd("RPOPLPUSH", source, destination) + c.Process(cmd) + return cmd } func (c *Client) RPush(key string, values ...string) *IntCmd { args := append([]string{"RPUSH", key}, values...) - req := NewIntCmd(args...) - c.Process(req) - return req + cmd := NewIntCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) RPushX(key string, value string) *IntCmd { - req := NewIntCmd("RPUSHX", key, value) - c.Process(req) - return req + cmd := NewIntCmd("RPUSHX", key, value) + c.Process(cmd) + return cmd } //------------------------------------------------------------------------------ func (c *Client) SAdd(key string, members ...string) *IntCmd { args := append([]string{"SADD", key}, members...) - req := NewIntCmd(args...) - c.Process(req) - return req + cmd := NewIntCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) SCard(key string) *IntCmd { - req := NewIntCmd("SCARD", key) - c.Process(req) - return req + cmd := NewIntCmd("SCARD", key) + c.Process(cmd) + return cmd } func (c *Client) SDiff(keys ...string) *StringSliceCmd { args := append([]string{"SDIFF"}, keys...) - req := NewStringSliceCmd(args...) - c.Process(req) - return req + cmd := NewStringSliceCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) SDiffStore(destination string, keys ...string) *IntCmd { args := append([]string{"SDIFFSTORE", destination}, keys...) - req := NewIntCmd(args...) - c.Process(req) - return req + cmd := NewIntCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) SInter(keys ...string) *StringSliceCmd { args := append([]string{"SINTER"}, keys...) - req := NewStringSliceCmd(args...) - c.Process(req) - return req + cmd := NewStringSliceCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) SInterStore(destination string, keys ...string) *IntCmd { args := append([]string{"SINTERSTORE", destination}, keys...) - req := NewIntCmd(args...) - c.Process(req) - return req + cmd := NewIntCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) SIsMember(key, member string) *BoolCmd { - req := NewBoolCmd("SISMEMBER", key, member) - c.Process(req) - return req + cmd := NewBoolCmd("SISMEMBER", key, member) + c.Process(cmd) + return cmd } func (c *Client) SMembers(key string) *StringSliceCmd { - req := NewStringSliceCmd("SMEMBERS", key) - c.Process(req) - return req + cmd := NewStringSliceCmd("SMEMBERS", key) + c.Process(cmd) + return cmd } func (c *Client) SMove(source, destination, member string) *BoolCmd { - req := NewBoolCmd("SMOVE", source, destination, member) - c.Process(req) - return req + cmd := NewBoolCmd("SMOVE", source, destination, member) + c.Process(cmd) + return cmd } func (c *Client) SPop(key string) *StringCmd { - req := NewStringCmd("SPOP", key) - c.Process(req) - return req + cmd := NewStringCmd("SPOP", key) + c.Process(cmd) + return cmd } func (c *Client) SRandMember(key string) *StringCmd { - req := NewStringCmd("SRANDMEMBER", key) - c.Process(req) - return req + cmd := NewStringCmd("SRANDMEMBER", key) + c.Process(cmd) + return cmd } func (c *Client) SRem(key string, members ...string) *IntCmd { args := append([]string{"SREM", key}, members...) - req := NewIntCmd(args...) - c.Process(req) - return req + cmd := NewIntCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) SUnion(keys ...string) *StringSliceCmd { args := append([]string{"SUNION"}, keys...) - req := NewStringSliceCmd(args...) - c.Process(req) - return req + cmd := NewStringSliceCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) SUnionStore(destination string, keys ...string) *IntCmd { args := append([]string{"SUNIONSTORE", destination}, keys...) - req := NewIntCmd(args...) - c.Process(req) - return req + cmd := NewIntCmd(args...) + c.Process(cmd) + return cmd } //------------------------------------------------------------------------------ @@ -791,27 +791,27 @@ func (c *Client) ZAdd(key string, members ...Z) *IntCmd { for _, m := range members { args = append(args, formatFloat(m.Score), m.Member) } - req := NewIntCmd(args...) - c.Process(req) - return req + cmd := NewIntCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) ZCard(key string) *IntCmd { - req := NewIntCmd("ZCARD", key) - c.Process(req) - return req + cmd := NewIntCmd("ZCARD", key) + c.Process(cmd) + return cmd } func (c *Client) ZCount(key, min, max string) *IntCmd { - req := NewIntCmd("ZCOUNT", key, min, max) - c.Process(req) - return req + cmd := NewIntCmd("ZCOUNT", key, min, max) + c.Process(cmd) + return cmd } func (c *Client) ZIncrBy(key string, increment float64, member string) *FloatCmd { - req := NewFloatCmd("ZINCRBY", key, formatFloat(increment), member) - c.Process(req) - return req + cmd := NewFloatCmd("ZINCRBY", key, formatFloat(increment), member) + c.Process(cmd) + return cmd } func (c *Client) ZInterStore( @@ -830,9 +830,9 @@ func (c *Client) ZInterStore( if store.Aggregate != "" { args = append(args, "AGGREGATE", store.Aggregate) } - req := NewIntCmd(args...) - c.Process(req) - return req + cmd := NewIntCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) zRange(key string, start, stop int64, withScores bool) *StringSliceCmd { @@ -845,9 +845,9 @@ func (c *Client) zRange(key string, start, stop int64, withScores bool) *StringS if withScores { args = append(args, "WITHSCORES") } - req := NewStringSliceCmd(args...) - c.Process(req) - return req + cmd := NewStringSliceCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) ZRange(key string, start, stop int64) *StringSliceCmd { @@ -866,9 +866,9 @@ func (c *Client) ZRangeWithScoresMap(key string, start, stop int64) *StringFloat strconv.FormatInt(stop, 10), "WITHSCORES", } - req := NewStringFloatMapCmd(args...) - c.Process(req) - return req + cmd := NewStringFloatMapCmd(args...) + c.Process(cmd) + return cmd } type ZRangeByScore struct { @@ -890,9 +890,9 @@ func (c *Client) zRangeByScore(key string, opt ZRangeByScore, withScores bool) * strconv.FormatInt(opt.Count, 10), ) } - req := NewStringSliceCmd(args...) - c.Process(req) - return req + cmd := NewStringSliceCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) ZRangeByScore(key string, opt ZRangeByScore) *StringSliceCmd { @@ -913,39 +913,39 @@ func (c *Client) ZRangeByScoreWithScoresMap(key string, opt ZRangeByScore) *Stri strconv.FormatInt(opt.Count, 10), ) } - req := NewStringFloatMapCmd(args...) - c.Process(req) - return req + cmd := NewStringFloatMapCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) ZRank(key, member string) *IntCmd { - req := NewIntCmd("ZRANK", key, member) - c.Process(req) - return req + cmd := NewIntCmd("ZRANK", key, member) + c.Process(cmd) + return cmd } func (c *Client) ZRem(key string, members ...string) *IntCmd { args := append([]string{"ZREM", key}, members...) - req := NewIntCmd(args...) - c.Process(req) - return req + cmd := NewIntCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) ZRemRangeByRank(key string, start, stop int64) *IntCmd { - req := NewIntCmd( + cmd := NewIntCmd( "ZREMRANGEBYRANK", key, strconv.FormatInt(start, 10), strconv.FormatInt(stop, 10), ) - c.Process(req) - return req + c.Process(cmd) + return cmd } func (c *Client) ZRemRangeByScore(key, min, max string) *IntCmd { - req := NewIntCmd("ZREMRANGEBYSCORE", key, min, max) - c.Process(req) - return req + cmd := NewIntCmd("ZREMRANGEBYSCORE", key, min, max) + c.Process(cmd) + return cmd } func (c *Client) zRevRange(key, start, stop string, withScores bool) *StringSliceCmd { @@ -953,9 +953,9 @@ func (c *Client) zRevRange(key, start, stop string, withScores bool) *StringSlic if withScores { args = append(args, "WITHSCORES") } - req := NewStringSliceCmd(args...) - c.Process(req) - return req + cmd := NewStringSliceCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) ZRevRange(key, start, stop string) *StringSliceCmd { @@ -968,9 +968,9 @@ func (c *Client) ZRevRangeWithScores(key, start, stop string) *StringSliceCmd { func (c *Client) ZRevRangeWithScoresMap(key, start, stop string) *StringFloatMapCmd { args := []string{"ZREVRANGE", key, start, stop, "WITHSCORES"} - req := NewStringFloatMapCmd(args...) - c.Process(req) - return req + cmd := NewStringFloatMapCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) zRevRangeByScore(key string, opt ZRangeByScore, withScores bool) *StringSliceCmd { @@ -986,9 +986,9 @@ func (c *Client) zRevRangeByScore(key string, opt ZRangeByScore, withScores bool strconv.FormatInt(opt.Count, 10), ) } - req := NewStringSliceCmd(args...) - c.Process(req) - return req + cmd := NewStringSliceCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) ZRevRangeByScore(key string, opt ZRangeByScore) *StringSliceCmd { @@ -1009,21 +1009,21 @@ func (c *Client) ZRevRangeByScoreWithScoresMap(key string, opt ZRangeByScore) *S strconv.FormatInt(opt.Count, 10), ) } - req := NewStringFloatMapCmd(args...) - c.Process(req) - return req + cmd := NewStringFloatMapCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) ZRevRank(key, member string) *IntCmd { - req := NewIntCmd("ZREVRANK", key, member) - c.Process(req) - return req + cmd := NewIntCmd("ZREVRANK", key, member) + c.Process(cmd) + return cmd } func (c *Client) ZScore(key, member string) *FloatCmd { - req := NewFloatCmd("ZSCORE", key, member) - c.Process(req) - return req + cmd := NewFloatCmd("ZSCORE", key, member) + c.Process(cmd) + return cmd } func (c *Client) ZUnionStore( @@ -1042,89 +1042,89 @@ func (c *Client) ZUnionStore( if store.Aggregate != "" { args = append(args, "AGGREGATE", store.Aggregate) } - req := NewIntCmd(args...) - c.Process(req) - return req + cmd := NewIntCmd(args...) + c.Process(cmd) + return cmd } //------------------------------------------------------------------------------ func (c *Client) BgRewriteAOF() *StatusCmd { - req := NewStatusCmd("BGREWRITEAOF") - c.Process(req) - return req + cmd := NewStatusCmd("BGREWRITEAOF") + c.Process(cmd) + return cmd } func (c *Client) BgSave() *StatusCmd { - req := NewStatusCmd("BGSAVE") - c.Process(req) - return req + cmd := NewStatusCmd("BGSAVE") + c.Process(cmd) + return cmd } func (c *Client) ClientKill(ipPort string) *StatusCmd { - req := NewStatusCmd("CLIENT", "KILL", ipPort) - c.Process(req) - return req + cmd := NewStatusCmd("CLIENT", "KILL", ipPort) + c.Process(cmd) + return cmd } func (c *Client) ClientList() *StringCmd { - req := NewStringCmd("CLIENT", "LIST") - c.Process(req) - return req + cmd := NewStringCmd("CLIENT", "LIST") + c.Process(cmd) + return cmd } func (c *Client) ConfigGet(parameter string) *SliceCmd { - req := NewSliceCmd("CONFIG", "GET", parameter) - c.Process(req) - return req + cmd := NewSliceCmd("CONFIG", "GET", parameter) + c.Process(cmd) + return cmd } func (c *Client) ConfigResetStat() *StatusCmd { - req := NewStatusCmd("CONFIG", "RESETSTAT") - c.Process(req) - return req + cmd := NewStatusCmd("CONFIG", "RESETSTAT") + c.Process(cmd) + return cmd } func (c *Client) ConfigSet(parameter, value string) *StatusCmd { - req := NewStatusCmd("CONFIG", "SET", parameter, value) - c.Process(req) - return req + cmd := NewStatusCmd("CONFIG", "SET", parameter, value) + c.Process(cmd) + return cmd } func (c *Client) DbSize() *IntCmd { - req := NewIntCmd("DBSIZE") - c.Process(req) - return req + cmd := NewIntCmd("DBSIZE") + c.Process(cmd) + return cmd } func (c *Client) FlushAll() *StatusCmd { - req := NewStatusCmd("FLUSHALL") - c.Process(req) - return req + cmd := NewStatusCmd("FLUSHALL") + c.Process(cmd) + return cmd } func (c *Client) FlushDb() *StatusCmd { - req := NewStatusCmd("FLUSHDB") - c.Process(req) - return req + cmd := NewStatusCmd("FLUSHDB") + c.Process(cmd) + return cmd } func (c *Client) Info() *StringCmd { - req := NewStringCmd("INFO") - c.Process(req) - return req + cmd := NewStringCmd("INFO") + c.Process(cmd) + return cmd } func (c *Client) LastSave() *IntCmd { - req := NewIntCmd("LASTSAVE") - c.Process(req) - return req + cmd := NewIntCmd("LASTSAVE") + c.Process(cmd) + return cmd } func (c *Client) Save() *StatusCmd { - req := NewStatusCmd("SAVE") - c.Process(req) - return req + cmd := NewStatusCmd("SAVE") + c.Process(cmd) + return cmd } func (c *Client) shutdown(modifier string) *StatusCmd { @@ -1134,10 +1134,10 @@ func (c *Client) shutdown(modifier string) *StatusCmd { } else { args = []string{"SHUTDOWN", modifier} } - req := NewStatusCmd(args...) - c.Process(req) + cmd := NewStatusCmd(args...) + c.Process(cmd) c.Close() - return req + return cmd } func (c *Client) Shutdown() *StatusCmd { @@ -1153,9 +1153,9 @@ func (c *Client) ShutdownNoSave() *StatusCmd { } func (c *Client) SlaveOf(host, port string) *StatusCmd { - req := NewStatusCmd("SLAVEOF", host, port) - c.Process(req) - return req + cmd := NewStatusCmd("SLAVEOF", host, port) + c.Process(cmd) + return cmd } func (c *Client) SlowLog() { @@ -1167,60 +1167,60 @@ func (c *Client) Sync() { } func (c *Client) Time() *StringSliceCmd { - req := NewStringSliceCmd("TIME") - c.Process(req) - return req + cmd := NewStringSliceCmd("TIME") + c.Process(cmd) + return cmd } //------------------------------------------------------------------------------ func (c *Client) Eval(script string, keys []string, args []string) *Cmd { - reqArgs := []string{"EVAL", script, strconv.FormatInt(int64(len(keys)), 10)} - reqArgs = append(reqArgs, keys...) - reqArgs = append(reqArgs, args...) - req := NewCmd(reqArgs...) - c.Process(req) - return req + cmdArgs := []string{"EVAL", script, strconv.FormatInt(int64(len(keys)), 10)} + cmdArgs = append(cmdArgs, keys...) + cmdArgs = append(cmdArgs, args...) + cmd := NewCmd(cmdArgs...) + c.Process(cmd) + return cmd } func (c *Client) EvalSha(sha1 string, keys []string, args []string) *Cmd { - reqArgs := []string{"EVALSHA", sha1, strconv.FormatInt(int64(len(keys)), 10)} - reqArgs = append(reqArgs, keys...) - reqArgs = append(reqArgs, args...) - req := NewCmd(reqArgs...) - c.Process(req) - return req + cmdArgs := []string{"EVALSHA", sha1, strconv.FormatInt(int64(len(keys)), 10)} + cmdArgs = append(cmdArgs, keys...) + cmdArgs = append(cmdArgs, args...) + cmd := NewCmd(cmdArgs...) + c.Process(cmd) + return cmd } func (c *Client) ScriptExists(scripts ...string) *BoolSliceCmd { args := append([]string{"SCRIPT", "EXISTS"}, scripts...) - req := NewBoolSliceCmd(args...) - c.Process(req) - return req + cmd := NewBoolSliceCmd(args...) + c.Process(cmd) + return cmd } func (c *Client) ScriptFlush() *StatusCmd { - req := NewStatusCmd("SCRIPT", "FLUSH") - c.Process(req) - return req + cmd := NewStatusCmd("SCRIPT", "FLUSH") + c.Process(cmd) + return cmd } func (c *Client) ScriptKill() *StatusCmd { - req := NewStatusCmd("SCRIPT", "KILL") - c.Process(req) - return req + cmd := NewStatusCmd("SCRIPT", "KILL") + c.Process(cmd) + return cmd } func (c *Client) ScriptLoad(script string) *StringCmd { - req := NewStringCmd("SCRIPT", "LOAD", script) - c.Process(req) - return req + cmd := NewStringCmd("SCRIPT", "LOAD", script) + c.Process(cmd) + return cmd } //------------------------------------------------------------------------------ func (c *Client) DebugObject(key string) *StringCmd { - req := NewStringCmd("DEBUG", "OBJECT", key) - c.Process(req) - return req + cmd := NewStringCmd("DEBUG", "OBJECT", key) + c.Process(cmd) + return cmd }