redis - ActiveState ActiveGo 1.8
...

Package redis

import "github.com/go-redis/redis"
Overview
Index
Examples
Subdirectories

Overview ▾

Package redis implements a Redis client.

Example (CustomCommand)

Code:

Get := func(client *redis.Client, key string) *redis.StringCmd {
    cmd := redis.NewStringCmd("get", key)
    client.Process(cmd)
    return cmd
}

v, err := Get(client, "key_does_not_exist").Result()
fmt.Printf("%q %s", v, err)

Output:

"" redis: nil

Example (Instrumentation)

Code:

package redis_test

import (
    "fmt"
    "sync/atomic"
    "time"

    "github.com/go-redis/redis"
)

func Example_instrumentation() {
    ring := redis.NewRing(&redis.RingOptions{
        Addrs: map[string]string{
            "shard1": ":6379",
        },
    })
    ring.ForEachShard(func(client *redis.Client) error {
        wrapRedisProcess(client)
        return nil
    })

    for {
        ring.Ping()
    }
}

func wrapRedisProcess(client *redis.Client) {
    const precision = time.Microsecond
    var count, avgDur uint32

    go func() {
        for range time.Tick(3 * time.Second) {
            n := atomic.LoadUint32(&count)
            dur := time.Duration(atomic.LoadUint32(&avgDur)) * precision
            fmt.Printf("%s: processed=%d avg_dur=%s\n", client, n, dur)
        }
    }()

    client.WrapProcess(func(oldProcess func(redis.Cmder) error) func(redis.Cmder) error {
        return func(cmd redis.Cmder) error {
            start := time.Now()
            err := oldProcess(cmd)
            dur := time.Since(start)

            const decay = float64(1) / 100
            ms := float64(dur / precision)
            for {
                avg := atomic.LoadUint32(&avgDur)
                newAvg := uint32((1-decay)*float64(avg) + decay*ms)
                if atomic.CompareAndSwapUint32(&avgDur, avg, newAvg) {
                    break
                }
            }
            atomic.AddUint32(&count, 1)

            return err
        }
    })
}

Index ▾

Constants
func SetLogger(logger *log.Logger)
type BitCount
type BoolCmd
    func NewBoolCmd(args ...interface{}) *BoolCmd
    func NewBoolResult(val bool, err error) *BoolCmd
    func (cmd *BoolCmd) Err() error
    func (cmd *BoolCmd) Name() string
    func (cmd *BoolCmd) Result() (bool, error)
    func (cmd *BoolCmd) String() string
    func (cmd *BoolCmd) Val() bool
type BoolSliceCmd
    func NewBoolSliceCmd(args ...interface{}) *BoolSliceCmd
    func NewBoolSliceResult(val []bool, err error) *BoolSliceCmd
    func (cmd *BoolSliceCmd) Err() error
    func (cmd *BoolSliceCmd) Name() string
    func (cmd *BoolSliceCmd) Result() ([]bool, error)
    func (cmd *BoolSliceCmd) String() string
    func (cmd *BoolSliceCmd) Val() []bool
type Client
    func NewClient(opt *Options) *Client
    func NewFailoverClient(failoverOpt *FailoverOptions) *Client
    func (c *Client) Append(key, value string) *IntCmd
    func (c *Client) BLPop(timeout time.Duration, keys ...string) *StringSliceCmd
    func (c *Client) BRPop(timeout time.Duration, keys ...string) *StringSliceCmd
    func (c *Client) BRPopLPush(source, destination string, timeout time.Duration) *StringCmd
    func (c *Client) BgRewriteAOF() *StatusCmd
    func (c *Client) BgSave() *StatusCmd
    func (c *Client) BitCount(key string, bitCount *BitCount) *IntCmd
    func (c *Client) BitOpAnd(destKey string, keys ...string) *IntCmd
    func (c *Client) BitOpNot(destKey string, key string) *IntCmd
    func (c *Client) BitOpOr(destKey string, keys ...string) *IntCmd
    func (c *Client) BitOpXor(destKey string, keys ...string) *IntCmd
    func (c *Client) BitPos(key string, bit int64, pos ...int64) *IntCmd
    func (c *Client) ClientGetName() *StringCmd
    func (c *Client) ClientKill(ipPort string) *StatusCmd
    func (c *Client) ClientList() *StringCmd
    func (c *Client) ClientPause(dur time.Duration) *BoolCmd
    func (c *Client) Close() error
    func (c *Client) ClusterAddSlots(slots ...int) *StatusCmd
    func (c *Client) ClusterAddSlotsRange(min, max int) *StatusCmd
    func (c *Client) ClusterCountFailureReports(nodeID string) *IntCmd
    func (c *Client) ClusterCountKeysInSlot(slot int) *IntCmd
    func (c *Client) ClusterDelSlots(slots ...int) *StatusCmd
    func (c *Client) ClusterDelSlotsRange(min, max int) *StatusCmd
    func (c *Client) ClusterFailover() *StatusCmd
    func (c *Client) ClusterForget(nodeID string) *StatusCmd
    func (c *Client) ClusterInfo() *StringCmd
    func (c *Client) ClusterKeySlot(key string) *IntCmd
    func (c *Client) ClusterMeet(host, port string) *StatusCmd
    func (c *Client) ClusterNodes() *StringCmd
    func (c *Client) ClusterReplicate(nodeID string) *StatusCmd
    func (c *Client) ClusterResetHard() *StatusCmd
    func (c *Client) ClusterResetSoft() *StatusCmd
    func (c *Client) ClusterSaveConfig() *StatusCmd
    func (c *Client) ClusterSlaves(nodeID string) *StringSliceCmd
    func (c *Client) ClusterSlots() *ClusterSlotsCmd
    func (c *Client) Command() *CommandsInfoCmd
    func (c *Client) ConfigGet(parameter string) *SliceCmd
    func (c *Client) ConfigResetStat() *StatusCmd
    func (c *Client) ConfigSet(parameter, value string) *StatusCmd
    func (c *Client) Context() context.Context
    func (c *Client) DbSize() *IntCmd
    func (c *Client) DebugObject(key string) *StringCmd
    func (c *Client) Decr(key string) *IntCmd
    func (c *Client) DecrBy(key string, decrement int64) *IntCmd
    func (c *Client) Del(keys ...string) *IntCmd
    func (c *Client) Dump(key string) *StringCmd
    func (c *Client) Echo(message interface{}) *StringCmd
    func (c *Client) Eval(script string, keys []string, args ...interface{}) *Cmd
    func (c *Client) EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd
    func (c *Client) Exists(keys ...string) *IntCmd
    func (c *Client) Expire(key string, expiration time.Duration) *BoolCmd
    func (c *Client) ExpireAt(key string, tm time.Time) *BoolCmd
    func (c *Client) FlushAll() *StatusCmd
    func (c *Client) FlushAllAsync() *StatusCmd
    func (c *Client) FlushDB() *StatusCmd
    func (c *Client) FlushDBAsync() *StatusCmd
    func (c *Client) FlushDb() *StatusCmd
    func (c *Client) GeoAdd(key string, geoLocation ...*GeoLocation) *IntCmd
    func (c *Client) GeoDist(key string, member1, member2, unit string) *FloatCmd
    func (c *Client) GeoHash(key string, members ...string) *StringSliceCmd
    func (c *Client) GeoPos(key string, members ...string) *GeoPosCmd
    func (c *Client) GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd
    func (c *Client) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) *GeoLocationCmd
    func (c *Client) Get(key string) *StringCmd
    func (c *Client) GetBit(key string, offset int64) *IntCmd
    func (c *Client) GetRange(key string, start, end int64) *StringCmd
    func (c *Client) GetSet(key string, value interface{}) *StringCmd
    func (c *Client) HDel(key string, fields ...string) *IntCmd
    func (c *Client) HExists(key, field string) *BoolCmd
    func (c *Client) HGet(key, field string) *StringCmd
    func (c *Client) HGetAll(key string) *StringStringMapCmd
    func (c *Client) HIncrBy(key, field string, incr int64) *IntCmd
    func (c *Client) HIncrByFloat(key, field string, incr float64) *FloatCmd
    func (c *Client) HKeys(key string) *StringSliceCmd
    func (c *Client) HLen(key string) *IntCmd
    func (c *Client) HMGet(key string, fields ...string) *SliceCmd
    func (c *Client) HMSet(key string, fields map[string]interface{}) *StatusCmd
    func (c *Client) HScan(key string, cursor uint64, match string, count int64) *ScanCmd
    func (c *Client) HSet(key, field string, value interface{}) *BoolCmd
    func (c *Client) HSetNX(key, field string, value interface{}) *BoolCmd
    func (c *Client) HVals(key string) *StringSliceCmd
    func (c *Client) Incr(key string) *IntCmd
    func (c *Client) IncrBy(key string, value int64) *IntCmd
    func (c *Client) IncrByFloat(key string, value float64) *FloatCmd
    func (c *Client) Info(section ...string) *StringCmd
    func (c *Client) Keys(pattern string) *StringSliceCmd
    func (c *Client) LIndex(key string, index int64) *StringCmd
    func (c *Client) LInsert(key, op string, pivot, value interface{}) *IntCmd
    func (c *Client) LInsertAfter(key string, pivot, value interface{}) *IntCmd
    func (c *Client) LInsertBefore(key string, pivot, value interface{}) *IntCmd
    func (c *Client) LLen(key string) *IntCmd
    func (c *Client) LPop(key string) *StringCmd
    func (c *Client) LPush(key string, values ...interface{}) *IntCmd
    func (c *Client) LPushX(key string, value interface{}) *IntCmd
    func (c *Client) LRange(key string, start, stop int64) *StringSliceCmd
    func (c *Client) LRem(key string, count int64, value interface{}) *IntCmd
    func (c *Client) LSet(key string, index int64, value interface{}) *StatusCmd
    func (c *Client) LTrim(key string, start, stop int64) *StatusCmd
    func (c *Client) LastSave() *IntCmd
    func (c *Client) MGet(keys ...string) *SliceCmd
    func (c *Client) MSet(pairs ...interface{}) *StatusCmd
    func (c *Client) MSetNX(pairs ...interface{}) *BoolCmd
    func (c *Client) Migrate(host, port, key string, db int64, timeout time.Duration) *StatusCmd
    func (c *Client) Move(key string, db int64) *BoolCmd
    func (c *Client) ObjectEncoding(key string) *StringCmd
    func (c *Client) ObjectIdleTime(key string) *DurationCmd
    func (c *Client) ObjectRefCount(key string) *IntCmd
    func (c *Client) Options() *Options
    func (c *Client) PExpire(key string, expiration time.Duration) *BoolCmd
    func (c *Client) PExpireAt(key string, tm time.Time) *BoolCmd
    func (c *Client) PFAdd(key string, els ...interface{}) *IntCmd
    func (c *Client) PFCount(keys ...string) *IntCmd
    func (c *Client) PFMerge(dest string, keys ...string) *StatusCmd
    func (c *Client) PSubscribe(channels ...string) *PubSub
    func (c *Client) PTTL(key string) *DurationCmd
    func (c *Client) Persist(key string) *BoolCmd
    func (c *Client) Ping() *StatusCmd
    func (c *Client) Pipeline() Pipeliner
    func (c *Client) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)
    func (c *Client) PoolStats() *PoolStats
    func (c *Client) Process(cmd Cmder) error
    func (c *Client) PubSubChannels(pattern string) *StringSliceCmd
    func (c *Client) PubSubNumPat() *IntCmd
    func (c *Client) PubSubNumSub(channels ...string) *StringIntMapCmd
    func (c *Client) Publish(channel, message string) *IntCmd
    func (c *Client) Quit() *StatusCmd
    func (c *Client) RPop(key string) *StringCmd
    func (c *Client) RPopLPush(source, destination string) *StringCmd
    func (c *Client) RPush(key string, values ...interface{}) *IntCmd
    func (c *Client) RPushX(key string, value interface{}) *IntCmd
    func (c *Client) RandomKey() *StringCmd
    func (c *Client) Rename(key, newkey string) *StatusCmd
    func (c *Client) RenameNX(key, newkey string) *BoolCmd
    func (c *Client) Restore(key string, ttl time.Duration, value string) *StatusCmd
    func (c *Client) RestoreReplace(key string, ttl time.Duration, value string) *StatusCmd
    func (c *Client) SAdd(key string, members ...interface{}) *IntCmd
    func (c *Client) SCard(key string) *IntCmd
    func (c *Client) SDiff(keys ...string) *StringSliceCmd
    func (c *Client) SDiffStore(destination string, keys ...string) *IntCmd
    func (c *Client) SInter(keys ...string) *StringSliceCmd
    func (c *Client) SInterStore(destination string, keys ...string) *IntCmd
    func (c *Client) SIsMember(key string, member interface{}) *BoolCmd
    func (c *Client) SMembers(key string) *StringSliceCmd
    func (c *Client) SMove(source, destination string, member interface{}) *BoolCmd
    func (c *Client) SPop(key string) *StringCmd
    func (c *Client) SPopN(key string, count int64) *StringSliceCmd
    func (c *Client) SRandMember(key string) *StringCmd
    func (c *Client) SRandMemberN(key string, count int64) *StringSliceCmd
    func (c *Client) SRem(key string, members ...interface{}) *IntCmd
    func (c *Client) SScan(key string, cursor uint64, match string, count int64) *ScanCmd
    func (c *Client) SUnion(keys ...string) *StringSliceCmd
    func (c *Client) SUnionStore(destination string, keys ...string) *IntCmd
    func (c *Client) Save() *StatusCmd
    func (c *Client) Scan(cursor uint64, match string, count int64) *ScanCmd
    func (c *Client) ScriptExists(scripts ...string) *BoolSliceCmd
    func (c *Client) ScriptFlush() *StatusCmd
    func (c *Client) ScriptKill() *StatusCmd
    func (c *Client) ScriptLoad(script string) *StringCmd
    func (c *Client) Set(key string, value interface{}, expiration time.Duration) *StatusCmd
    func (c *Client) SetBit(key string, offset int64, value int) *IntCmd
    func (c *Client) SetNX(key string, value interface{}, expiration time.Duration) *BoolCmd
    func (c *Client) SetRange(key string, offset int64, value string) *IntCmd
    func (c *Client) SetXX(key string, value interface{}, expiration time.Duration) *BoolCmd
    func (c *Client) Shutdown() *StatusCmd
    func (c *Client) ShutdownNoSave() *StatusCmd
    func (c *Client) ShutdownSave() *StatusCmd
    func (c *Client) SlaveOf(host, port string) *StatusCmd
    func (c *Client) SlowLog()
    func (c *Client) Sort(key string, sort Sort) *StringSliceCmd
    func (c *Client) SortInterfaces(key string, sort Sort) *SliceCmd
    func (c *Client) StrLen(key string) *IntCmd
    func (c *Client) String() string
    func (c *Client) Subscribe(channels ...string) *PubSub
    func (c *Client) Sync()
    func (c *Client) TTL(key string) *DurationCmd
    func (c *Client) Time() *TimeCmd
    func (c *Client) TxPipeline() Pipeliner
    func (c *Client) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error)
    func (c *Client) Type(key string) *StatusCmd
    func (c *Client) Unlink(keys ...string) *IntCmd
    func (c *Client) Wait(numSlaves int, timeout time.Duration) *IntCmd
    func (c *Client) Watch(fn func(*Tx) error, keys ...string) error
    func (c *Client) WithContext(ctx context.Context) *Client
    func (c *Client) WrapProcess(fn func(oldProcess func(cmd Cmder) error) func(cmd Cmder) error)
    func (c *Client) ZAdd(key string, members ...Z) *IntCmd
    func (c *Client) ZAddCh(key string, members ...Z) *IntCmd
    func (c *Client) ZAddNX(key string, members ...Z) *IntCmd
    func (c *Client) ZAddNXCh(key string, members ...Z) *IntCmd
    func (c *Client) ZAddXX(key string, members ...Z) *IntCmd
    func (c *Client) ZAddXXCh(key string, members ...Z) *IntCmd
    func (c *Client) ZCard(key string) *IntCmd
    func (c *Client) ZCount(key, min, max string) *IntCmd
    func (c *Client) ZIncr(key string, member Z) *FloatCmd
    func (c *Client) ZIncrBy(key string, increment float64, member string) *FloatCmd
    func (c *Client) ZIncrNX(key string, member Z) *FloatCmd
    func (c *Client) ZIncrXX(key string, member Z) *FloatCmd
    func (c *Client) ZInterStore(destination string, store ZStore, keys ...string) *IntCmd
    func (c *Client) ZRange(key string, start, stop int64) *StringSliceCmd
    func (c *Client) ZRangeByLex(key string, opt ZRangeBy) *StringSliceCmd
    func (c *Client) ZRangeByScore(key string, opt ZRangeBy) *StringSliceCmd
    func (c *Client) ZRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd
    func (c *Client) ZRangeWithScores(key string, start, stop int64) *ZSliceCmd
    func (c *Client) ZRank(key, member string) *IntCmd
    func (c *Client) ZRem(key string, members ...interface{}) *IntCmd
    func (c *Client) ZRemRangeByLex(key, min, max string) *IntCmd
    func (c *Client) ZRemRangeByRank(key string, start, stop int64) *IntCmd
    func (c *Client) ZRemRangeByScore(key, min, max string) *IntCmd
    func (c *Client) ZRevRange(key string, start, stop int64) *StringSliceCmd
    func (c *Client) ZRevRangeByLex(key string, opt ZRangeBy) *StringSliceCmd
    func (c *Client) ZRevRangeByScore(key string, opt ZRangeBy) *StringSliceCmd
    func (c *Client) ZRevRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd
    func (c *Client) ZRevRangeWithScores(key string, start, stop int64) *ZSliceCmd
    func (c *Client) ZRevRank(key, member string) *IntCmd
    func (c *Client) ZScan(key string, cursor uint64, match string, count int64) *ScanCmd
    func (c *Client) ZScore(key, member string) *FloatCmd
    func (c *Client) ZUnionStore(dest string, store ZStore, keys ...string) *IntCmd
type ClusterClient
    func NewClusterClient(opt *ClusterOptions) *ClusterClient
    func (c *ClusterClient) Append(key, value string) *IntCmd
    func (c *ClusterClient) BLPop(timeout time.Duration, keys ...string) *StringSliceCmd
    func (c *ClusterClient) BRPop(timeout time.Duration, keys ...string) *StringSliceCmd
    func (c *ClusterClient) BRPopLPush(source, destination string, timeout time.Duration) *StringCmd
    func (c *ClusterClient) BgRewriteAOF() *StatusCmd
    func (c *ClusterClient) BgSave() *StatusCmd
    func (c *ClusterClient) BitCount(key string, bitCount *BitCount) *IntCmd
    func (c *ClusterClient) BitOpAnd(destKey string, keys ...string) *IntCmd
    func (c *ClusterClient) BitOpNot(destKey string, key string) *IntCmd
    func (c *ClusterClient) BitOpOr(destKey string, keys ...string) *IntCmd
    func (c *ClusterClient) BitOpXor(destKey string, keys ...string) *IntCmd
    func (c *ClusterClient) BitPos(key string, bit int64, pos ...int64) *IntCmd
    func (c *ClusterClient) ClientGetName() *StringCmd
    func (c *ClusterClient) ClientKill(ipPort string) *StatusCmd
    func (c *ClusterClient) ClientList() *StringCmd
    func (c *ClusterClient) ClientPause(dur time.Duration) *BoolCmd
    func (c *ClusterClient) Close() error
    func (c *ClusterClient) ClusterAddSlots(slots ...int) *StatusCmd
    func (c *ClusterClient) ClusterAddSlotsRange(min, max int) *StatusCmd
    func (c *ClusterClient) ClusterCountFailureReports(nodeID string) *IntCmd
    func (c *ClusterClient) ClusterCountKeysInSlot(slot int) *IntCmd
    func (c *ClusterClient) ClusterDelSlots(slots ...int) *StatusCmd
    func (c *ClusterClient) ClusterDelSlotsRange(min, max int) *StatusCmd
    func (c *ClusterClient) ClusterFailover() *StatusCmd
    func (c *ClusterClient) ClusterForget(nodeID string) *StatusCmd
    func (c *ClusterClient) ClusterInfo() *StringCmd
    func (c *ClusterClient) ClusterKeySlot(key string) *IntCmd
    func (c *ClusterClient) ClusterMeet(host, port string) *StatusCmd
    func (c *ClusterClient) ClusterNodes() *StringCmd
    func (c *ClusterClient) ClusterReplicate(nodeID string) *StatusCmd
    func (c *ClusterClient) ClusterResetHard() *StatusCmd
    func (c *ClusterClient) ClusterResetSoft() *StatusCmd
    func (c *ClusterClient) ClusterSaveConfig() *StatusCmd
    func (c *ClusterClient) ClusterSlaves(nodeID string) *StringSliceCmd
    func (c *ClusterClient) ClusterSlots() *ClusterSlotsCmd
    func (c *ClusterClient) Command() *CommandsInfoCmd
    func (c *ClusterClient) ConfigGet(parameter string) *SliceCmd
    func (c *ClusterClient) ConfigResetStat() *StatusCmd
    func (c *ClusterClient) ConfigSet(parameter, value string) *StatusCmd
    func (c *ClusterClient) DbSize() *IntCmd
    func (c *ClusterClient) DebugObject(key string) *StringCmd
    func (c *ClusterClient) Decr(key string) *IntCmd
    func (c *ClusterClient) DecrBy(key string, decrement int64) *IntCmd
    func (c *ClusterClient) Del(keys ...string) *IntCmd
    func (c *ClusterClient) Dump(key string) *StringCmd
    func (c *ClusterClient) Echo(message interface{}) *StringCmd
    func (c *ClusterClient) Eval(script string, keys []string, args ...interface{}) *Cmd
    func (c *ClusterClient) EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd
    func (c *ClusterClient) Exists(keys ...string) *IntCmd
    func (c *ClusterClient) Expire(key string, expiration time.Duration) *BoolCmd
    func (c *ClusterClient) ExpireAt(key string, tm time.Time) *BoolCmd
    func (c *ClusterClient) FlushAll() *StatusCmd
    func (c *ClusterClient) FlushAllAsync() *StatusCmd
    func (c *ClusterClient) FlushDB() *StatusCmd
    func (c *ClusterClient) FlushDBAsync() *StatusCmd
    func (c *ClusterClient) FlushDb() *StatusCmd
    func (c *ClusterClient) ForEachMaster(fn func(client *Client) error) error
    func (c *ClusterClient) ForEachNode(fn func(client *Client) error) error
    func (c *ClusterClient) GeoAdd(key string, geoLocation ...*GeoLocation) *IntCmd
    func (c *ClusterClient) GeoDist(key string, member1, member2, unit string) *FloatCmd
    func (c *ClusterClient) GeoHash(key string, members ...string) *StringSliceCmd
    func (c *ClusterClient) GeoPos(key string, members ...string) *GeoPosCmd
    func (c *ClusterClient) GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd
    func (c *ClusterClient) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) *GeoLocationCmd
    func (c *ClusterClient) Get(key string) *StringCmd
    func (c *ClusterClient) GetBit(key string, offset int64) *IntCmd
    func (c *ClusterClient) GetRange(key string, start, end int64) *StringCmd
    func (c *ClusterClient) GetSet(key string, value interface{}) *StringCmd
    func (c *ClusterClient) HDel(key string, fields ...string) *IntCmd
    func (c *ClusterClient) HExists(key, field string) *BoolCmd
    func (c *ClusterClient) HGet(key, field string) *StringCmd
    func (c *ClusterClient) HGetAll(key string) *StringStringMapCmd
    func (c *ClusterClient) HIncrBy(key, field string, incr int64) *IntCmd
    func (c *ClusterClient) HIncrByFloat(key, field string, incr float64) *FloatCmd
    func (c *ClusterClient) HKeys(key string) *StringSliceCmd
    func (c *ClusterClient) HLen(key string) *IntCmd
    func (c *ClusterClient) HMGet(key string, fields ...string) *SliceCmd
    func (c *ClusterClient) HMSet(key string, fields map[string]interface{}) *StatusCmd
    func (c *ClusterClient) HScan(key string, cursor uint64, match string, count int64) *ScanCmd
    func (c *ClusterClient) HSet(key, field string, value interface{}) *BoolCmd
    func (c *ClusterClient) HSetNX(key, field string, value interface{}) *BoolCmd
    func (c *ClusterClient) HVals(key string) *StringSliceCmd
    func (c *ClusterClient) Incr(key string) *IntCmd
    func (c *ClusterClient) IncrBy(key string, value int64) *IntCmd
    func (c *ClusterClient) IncrByFloat(key string, value float64) *FloatCmd
    func (c *ClusterClient) Info(section ...string) *StringCmd
    func (c *ClusterClient) Keys(pattern string) *StringSliceCmd
    func (c *ClusterClient) LIndex(key string, index int64) *StringCmd
    func (c *ClusterClient) LInsert(key, op string, pivot, value interface{}) *IntCmd
    func (c *ClusterClient) LInsertAfter(key string, pivot, value interface{}) *IntCmd
    func (c *ClusterClient) LInsertBefore(key string, pivot, value interface{}) *IntCmd
    func (c *ClusterClient) LLen(key string) *IntCmd
    func (c *ClusterClient) LPop(key string) *StringCmd
    func (c *ClusterClient) LPush(key string, values ...interface{}) *IntCmd
    func (c *ClusterClient) LPushX(key string, value interface{}) *IntCmd
    func (c *ClusterClient) LRange(key string, start, stop int64) *StringSliceCmd
    func (c *ClusterClient) LRem(key string, count int64, value interface{}) *IntCmd
    func (c *ClusterClient) LSet(key string, index int64, value interface{}) *StatusCmd
    func (c *ClusterClient) LTrim(key string, start, stop int64) *StatusCmd
    func (c *ClusterClient) LastSave() *IntCmd
    func (c *ClusterClient) MGet(keys ...string) *SliceCmd
    func (c *ClusterClient) MSet(pairs ...interface{}) *StatusCmd
    func (c *ClusterClient) MSetNX(pairs ...interface{}) *BoolCmd
    func (c *ClusterClient) Migrate(host, port, key string, db int64, timeout time.Duration) *StatusCmd
    func (c *ClusterClient) Move(key string, db int64) *BoolCmd
    func (c *ClusterClient) ObjectEncoding(key string) *StringCmd
    func (c *ClusterClient) ObjectIdleTime(key string) *DurationCmd
    func (c *ClusterClient) ObjectRefCount(key string) *IntCmd
    func (c *ClusterClient) Options() *ClusterOptions
    func (c *ClusterClient) PExpire(key string, expiration time.Duration) *BoolCmd
    func (c *ClusterClient) PExpireAt(key string, tm time.Time) *BoolCmd
    func (c *ClusterClient) PFAdd(key string, els ...interface{}) *IntCmd
    func (c *ClusterClient) PFCount(keys ...string) *IntCmd
    func (c *ClusterClient) PFMerge(dest string, keys ...string) *StatusCmd
    func (c *ClusterClient) PTTL(key string) *DurationCmd
    func (c *ClusterClient) Persist(key string) *BoolCmd
    func (c *ClusterClient) Ping() *StatusCmd
    func (c *ClusterClient) Pipeline() Pipeliner
    func (c *ClusterClient) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)
    func (c *ClusterClient) PoolStats() *PoolStats
    func (c *ClusterClient) Process(cmd Cmder) error
    func (c *ClusterClient) PubSubChannels(pattern string) *StringSliceCmd
    func (c *ClusterClient) PubSubNumPat() *IntCmd
    func (c *ClusterClient) PubSubNumSub(channels ...string) *StringIntMapCmd
    func (c *ClusterClient) Publish(channel, message string) *IntCmd
    func (c *ClusterClient) Quit() *StatusCmd
    func (c *ClusterClient) RPop(key string) *StringCmd
    func (c *ClusterClient) RPopLPush(source, destination string) *StringCmd
    func (c *ClusterClient) RPush(key string, values ...interface{}) *IntCmd
    func (c *ClusterClient) RPushX(key string, value interface{}) *IntCmd
    func (c *ClusterClient) RandomKey() *StringCmd
    func (c *ClusterClient) Rename(key, newkey string) *StatusCmd
    func (c *ClusterClient) RenameNX(key, newkey string) *BoolCmd
    func (c *ClusterClient) Restore(key string, ttl time.Duration, value string) *StatusCmd
    func (c *ClusterClient) RestoreReplace(key string, ttl time.Duration, value string) *StatusCmd
    func (c *ClusterClient) SAdd(key string, members ...interface{}) *IntCmd
    func (c *ClusterClient) SCard(key string) *IntCmd
    func (c *ClusterClient) SDiff(keys ...string) *StringSliceCmd
    func (c *ClusterClient) SDiffStore(destination string, keys ...string) *IntCmd
    func (c *ClusterClient) SInter(keys ...string) *StringSliceCmd
    func (c *ClusterClient) SInterStore(destination string, keys ...string) *IntCmd
    func (c *ClusterClient) SIsMember(key string, member interface{}) *BoolCmd
    func (c *ClusterClient) SMembers(key string) *StringSliceCmd
    func (c *ClusterClient) SMove(source, destination string, member interface{}) *BoolCmd
    func (c *ClusterClient) SPop(key string) *StringCmd
    func (c *ClusterClient) SPopN(key string, count int64) *StringSliceCmd
    func (c *ClusterClient) SRandMember(key string) *StringCmd
    func (c *ClusterClient) SRandMemberN(key string, count int64) *StringSliceCmd
    func (c *ClusterClient) SRem(key string, members ...interface{}) *IntCmd
    func (c *ClusterClient) SScan(key string, cursor uint64, match string, count int64) *ScanCmd
    func (c *ClusterClient) SUnion(keys ...string) *StringSliceCmd
    func (c *ClusterClient) SUnionStore(destination string, keys ...string) *IntCmd
    func (c *ClusterClient) Save() *StatusCmd
    func (c *ClusterClient) Scan(cursor uint64, match string, count int64) *ScanCmd
    func (c *ClusterClient) ScriptExists(scripts ...string) *BoolSliceCmd
    func (c *ClusterClient) ScriptFlush() *StatusCmd
    func (c *ClusterClient) ScriptKill() *StatusCmd
    func (c *ClusterClient) ScriptLoad(script string) *StringCmd
    func (c *ClusterClient) Set(key string, value interface{}, expiration time.Duration) *StatusCmd
    func (c *ClusterClient) SetBit(key string, offset int64, value int) *IntCmd
    func (c *ClusterClient) SetNX(key string, value interface{}, expiration time.Duration) *BoolCmd
    func (c *ClusterClient) SetRange(key string, offset int64, value string) *IntCmd
    func (c *ClusterClient) SetXX(key string, value interface{}, expiration time.Duration) *BoolCmd
    func (c *ClusterClient) Shutdown() *StatusCmd
    func (c *ClusterClient) ShutdownNoSave() *StatusCmd
    func (c *ClusterClient) ShutdownSave() *StatusCmd
    func (c *ClusterClient) SlaveOf(host, port string) *StatusCmd
    func (c *ClusterClient) SlowLog()
    func (c *ClusterClient) Sort(key string, sort Sort) *StringSliceCmd
    func (c *ClusterClient) SortInterfaces(key string, sort Sort) *SliceCmd
    func (c *ClusterClient) StrLen(key string) *IntCmd
    func (c *ClusterClient) Sync()
    func (c *ClusterClient) TTL(key string) *DurationCmd
    func (c *ClusterClient) Time() *TimeCmd
    func (c *ClusterClient) TxPipeline() Pipeliner
    func (c *ClusterClient) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error)
    func (c *ClusterClient) Type(key string) *StatusCmd
    func (c *ClusterClient) Unlink(keys ...string) *IntCmd
    func (c *ClusterClient) Wait(numSlaves int, timeout time.Duration) *IntCmd
    func (c *ClusterClient) Watch(fn func(*Tx) error, keys ...string) error
    func (c *ClusterClient) ZAdd(key string, members ...Z) *IntCmd
    func (c *ClusterClient) ZAddCh(key string, members ...Z) *IntCmd
    func (c *ClusterClient) ZAddNX(key string, members ...Z) *IntCmd
    func (c *ClusterClient) ZAddNXCh(key string, members ...Z) *IntCmd
    func (c *ClusterClient) ZAddXX(key string, members ...Z) *IntCmd
    func (c *ClusterClient) ZAddXXCh(key string, members ...Z) *IntCmd
    func (c *ClusterClient) ZCard(key string) *IntCmd
    func (c *ClusterClient) ZCount(key, min, max string) *IntCmd
    func (c *ClusterClient) ZIncr(key string, member Z) *FloatCmd
    func (c *ClusterClient) ZIncrBy(key string, increment float64, member string) *FloatCmd
    func (c *ClusterClient) ZIncrNX(key string, member Z) *FloatCmd
    func (c *ClusterClient) ZIncrXX(key string, member Z) *FloatCmd
    func (c *ClusterClient) ZInterStore(destination string, store ZStore, keys ...string) *IntCmd
    func (c *ClusterClient) ZRange(key string, start, stop int64) *StringSliceCmd
    func (c *ClusterClient) ZRangeByLex(key string, opt ZRangeBy) *StringSliceCmd
    func (c *ClusterClient) ZRangeByScore(key string, opt ZRangeBy) *StringSliceCmd
    func (c *ClusterClient) ZRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd
    func (c *ClusterClient) ZRangeWithScores(key string, start, stop int64) *ZSliceCmd
    func (c *ClusterClient) ZRank(key, member string) *IntCmd
    func (c *ClusterClient) ZRem(key string, members ...interface{}) *IntCmd
    func (c *ClusterClient) ZRemRangeByLex(key, min, max string) *IntCmd
    func (c *ClusterClient) ZRemRangeByRank(key string, start, stop int64) *IntCmd
    func (c *ClusterClient) ZRemRangeByScore(key, min, max string) *IntCmd
    func (c *ClusterClient) ZRevRange(key string, start, stop int64) *StringSliceCmd
    func (c *ClusterClient) ZRevRangeByLex(key string, opt ZRangeBy) *StringSliceCmd
    func (c *ClusterClient) ZRevRangeByScore(key string, opt ZRangeBy) *StringSliceCmd
    func (c *ClusterClient) ZRevRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd
    func (c *ClusterClient) ZRevRangeWithScores(key string, start, stop int64) *ZSliceCmd
    func (c *ClusterClient) ZRevRank(key, member string) *IntCmd
    func (c *ClusterClient) ZScan(key string, cursor uint64, match string, count int64) *ScanCmd
    func (c *ClusterClient) ZScore(key, member string) *FloatCmd
    func (c *ClusterClient) ZUnionStore(dest string, store ZStore, keys ...string) *IntCmd
type ClusterNode
type ClusterOptions
type ClusterSlot
type ClusterSlotsCmd
    func NewClusterSlotsCmd(args ...interface{}) *ClusterSlotsCmd
    func NewClusterSlotsCmdResult(val []ClusterSlot, err error) *ClusterSlotsCmd
    func (cmd *ClusterSlotsCmd) Err() error
    func (cmd *ClusterSlotsCmd) Name() string
    func (cmd *ClusterSlotsCmd) Result() ([]ClusterSlot, error)
    func (cmd *ClusterSlotsCmd) String() string
    func (cmd *ClusterSlotsCmd) Val() []ClusterSlot
type Cmd
    func NewCmd(args ...interface{}) *Cmd
    func NewCmdResult(val interface{}, err error) *Cmd
    func (cmd *Cmd) Err() error
    func (cmd *Cmd) Name() string
    func (cmd *Cmd) Result() (interface{}, error)
    func (cmd *Cmd) String() string
    func (cmd *Cmd) Val() interface{}
type Cmdable
type Cmder
type CommandInfo
type CommandsInfoCmd
    func NewCommandsInfoCmd(args ...interface{}) *CommandsInfoCmd
    func NewCommandsInfoCmdResult(val map[string]*CommandInfo, err error) *CommandsInfoCmd
    func (cmd *CommandsInfoCmd) Err() error
    func (cmd *CommandsInfoCmd) Name() string
    func (cmd *CommandsInfoCmd) Result() (map[string]*CommandInfo, error)
    func (cmd *CommandsInfoCmd) String() string
    func (cmd *CommandsInfoCmd) Val() map[string]*CommandInfo
type Conn
    func (c *Conn) Auth(password string) *StatusCmd
    func (c *Conn) ClientSetName(name string) *BoolCmd
    func (c *Conn) Close() error
    func (c *Conn) Pipeline() Pipeliner
    func (c *Conn) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)
    func (c *Conn) Process(cmd Cmder) error
    func (c *Conn) ReadOnly() *StatusCmd
    func (c *Conn) ReadWrite() *StatusCmd
    func (c *Conn) Select(index int) *StatusCmd
    func (c *Conn) String() string
    func (c *Conn) TxPipeline() Pipeliner
    func (c *Conn) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error)
    func (c *Conn) WrapProcess(fn func(oldProcess func(cmd Cmder) error) func(cmd Cmder) error)
type DurationCmd
    func NewDurationCmd(precision time.Duration, args ...interface{}) *DurationCmd
    func NewDurationResult(val time.Duration, err error) *DurationCmd
    func (cmd *DurationCmd) Err() error
    func (cmd *DurationCmd) Name() string
    func (cmd *DurationCmd) Result() (time.Duration, error)
    func (cmd *DurationCmd) String() string
    func (cmd *DurationCmd) Val() time.Duration
type FailoverOptions
type FloatCmd
    func NewFloatCmd(args ...interface{}) *FloatCmd
    func NewFloatResult(val float64, err error) *FloatCmd
    func (cmd *FloatCmd) Err() error
    func (cmd *FloatCmd) Name() string
    func (cmd *FloatCmd) Result() (float64, error)
    func (cmd *FloatCmd) String() string
    func (cmd *FloatCmd) Val() float64
type GeoLocation
type GeoLocationCmd
    func NewGeoLocationCmd(q *GeoRadiusQuery, args ...interface{}) *GeoLocationCmd
    func NewGeoLocationCmdResult(val []GeoLocation, err error) *GeoLocationCmd
    func (cmd *GeoLocationCmd) Err() error
    func (cmd *GeoLocationCmd) Name() string
    func (cmd *GeoLocationCmd) Result() ([]GeoLocation, error)
    func (cmd *GeoLocationCmd) String() string
    func (cmd *GeoLocationCmd) Val() []GeoLocation
type GeoPos
type GeoPosCmd
    func NewGeoPosCmd(args ...interface{}) *GeoPosCmd
    func (cmd *GeoPosCmd) Err() error
    func (cmd *GeoPosCmd) Name() string
    func (cmd *GeoPosCmd) Result() ([]*GeoPos, error)
    func (cmd *GeoPosCmd) String() string
    func (cmd *GeoPosCmd) Val() []*GeoPos
type GeoRadiusQuery
type IntCmd
    func NewIntCmd(args ...interface{}) *IntCmd
    func NewIntResult(val int64, err error) *IntCmd
    func (cmd *IntCmd) Err() error
    func (cmd *IntCmd) Name() string
    func (cmd *IntCmd) Result() (int64, error)
    func (cmd *IntCmd) String() string
    func (cmd *IntCmd) Val() int64
type Message
    func (m *Message) String() string
type Options
    func ParseURL(redisURL string) (*Options, error)
type Pipeline
    func (c *Pipeline) Auth(password string) *StatusCmd
    func (c *Pipeline) ClientSetName(name string) *BoolCmd
    func (c *Pipeline) Close() error
    func (c *Pipeline) Discard() error
    func (c *Pipeline) Exec() ([]Cmder, error)
    func (c *Pipeline) Pipeline() Pipeliner
    func (c *Pipeline) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)
    func (c *Pipeline) Process(cmd Cmder) error
    func (c *Pipeline) ReadOnly() *StatusCmd
    func (c *Pipeline) ReadWrite() *StatusCmd
    func (c *Pipeline) Select(index int) *StatusCmd
type Pipeliner
type Pong
    func (p *Pong) String() string
type PoolStats
type PubSub
    func (c *PubSub) Channel() <-chan *Message
    func (c *PubSub) Close() error
    func (c *PubSub) PSubscribe(patterns ...string) error
    func (c *PubSub) PUnsubscribe(patterns ...string) error
    func (c *PubSub) Ping(payload ...string) error
    func (c *PubSub) Receive() (interface{}, error)
    func (c *PubSub) ReceiveMessage() (*Message, error)
    func (c *PubSub) ReceiveTimeout(timeout time.Duration) (interface{}, error)
    func (c *PubSub) Subscribe(channels ...string) error
    func (c *PubSub) Unsubscribe(channels ...string) error
type Ring
    func NewRing(opt *RingOptions) *Ring
    func (c *Ring) Append(key, value string) *IntCmd
    func (c *Ring) BLPop(timeout time.Duration, keys ...string) *StringSliceCmd
    func (c *Ring) BRPop(timeout time.Duration, keys ...string) *StringSliceCmd
    func (c *Ring) BRPopLPush(source, destination string, timeout time.Duration) *StringCmd
    func (c *Ring) BgRewriteAOF() *StatusCmd
    func (c *Ring) BgSave() *StatusCmd
    func (c *Ring) BitCount(key string, bitCount *BitCount) *IntCmd
    func (c *Ring) BitOpAnd(destKey string, keys ...string) *IntCmd
    func (c *Ring) BitOpNot(destKey string, key string) *IntCmd
    func (c *Ring) BitOpOr(destKey string, keys ...string) *IntCmd
    func (c *Ring) BitOpXor(destKey string, keys ...string) *IntCmd
    func (c *Ring) BitPos(key string, bit int64, pos ...int64) *IntCmd
    func (c *Ring) ClientGetName() *StringCmd
    func (c *Ring) ClientKill(ipPort string) *StatusCmd
    func (c *Ring) ClientList() *StringCmd
    func (c *Ring) ClientPause(dur time.Duration) *BoolCmd
    func (c *Ring) Close() error
    func (c *Ring) ClusterAddSlots(slots ...int) *StatusCmd
    func (c *Ring) ClusterAddSlotsRange(min, max int) *StatusCmd
    func (c *Ring) ClusterCountFailureReports(nodeID string) *IntCmd
    func (c *Ring) ClusterCountKeysInSlot(slot int) *IntCmd
    func (c *Ring) ClusterDelSlots(slots ...int) *StatusCmd
    func (c *Ring) ClusterDelSlotsRange(min, max int) *StatusCmd
    func (c *Ring) ClusterFailover() *StatusCmd
    func (c *Ring) ClusterForget(nodeID string) *StatusCmd
    func (c *Ring) ClusterInfo() *StringCmd
    func (c *Ring) ClusterKeySlot(key string) *IntCmd
    func (c *Ring) ClusterMeet(host, port string) *StatusCmd
    func (c *Ring) ClusterNodes() *StringCmd
    func (c *Ring) ClusterReplicate(nodeID string) *StatusCmd
    func (c *Ring) ClusterResetHard() *StatusCmd
    func (c *Ring) ClusterResetSoft() *StatusCmd
    func (c *Ring) ClusterSaveConfig() *StatusCmd
    func (c *Ring) ClusterSlaves(nodeID string) *StringSliceCmd
    func (c *Ring) ClusterSlots() *ClusterSlotsCmd
    func (c *Ring) Command() *CommandsInfoCmd
    func (c *Ring) ConfigGet(parameter string) *SliceCmd
    func (c *Ring) ConfigResetStat() *StatusCmd
    func (c *Ring) ConfigSet(parameter, value string) *StatusCmd
    func (c *Ring) DbSize() *IntCmd
    func (c *Ring) DebugObject(key string) *StringCmd
    func (c *Ring) Decr(key string) *IntCmd
    func (c *Ring) DecrBy(key string, decrement int64) *IntCmd
    func (c *Ring) Del(keys ...string) *IntCmd
    func (c *Ring) Dump(key string) *StringCmd
    func (c *Ring) Echo(message interface{}) *StringCmd
    func (c *Ring) Eval(script string, keys []string, args ...interface{}) *Cmd
    func (c *Ring) EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd
    func (c *Ring) Exists(keys ...string) *IntCmd
    func (c *Ring) Expire(key string, expiration time.Duration) *BoolCmd
    func (c *Ring) ExpireAt(key string, tm time.Time) *BoolCmd
    func (c *Ring) FlushAll() *StatusCmd
    func (c *Ring) FlushAllAsync() *StatusCmd
    func (c *Ring) FlushDB() *StatusCmd
    func (c *Ring) FlushDBAsync() *StatusCmd
    func (c *Ring) FlushDb() *StatusCmd
    func (c *Ring) ForEachShard(fn func(client *Client) error) error
    func (c *Ring) GeoAdd(key string, geoLocation ...*GeoLocation) *IntCmd
    func (c *Ring) GeoDist(key string, member1, member2, unit string) *FloatCmd
    func (c *Ring) GeoHash(key string, members ...string) *StringSliceCmd
    func (c *Ring) GeoPos(key string, members ...string) *GeoPosCmd
    func (c *Ring) GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd
    func (c *Ring) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) *GeoLocationCmd
    func (c *Ring) Get(key string) *StringCmd
    func (c *Ring) GetBit(key string, offset int64) *IntCmd
    func (c *Ring) GetRange(key string, start, end int64) *StringCmd
    func (c *Ring) GetSet(key string, value interface{}) *StringCmd
    func (c *Ring) HDel(key string, fields ...string) *IntCmd
    func (c *Ring) HExists(key, field string) *BoolCmd
    func (c *Ring) HGet(key, field string) *StringCmd
    func (c *Ring) HGetAll(key string) *StringStringMapCmd
    func (c *Ring) HIncrBy(key, field string, incr int64) *IntCmd
    func (c *Ring) HIncrByFloat(key, field string, incr float64) *FloatCmd
    func (c *Ring) HKeys(key string) *StringSliceCmd
    func (c *Ring) HLen(key string) *IntCmd
    func (c *Ring) HMGet(key string, fields ...string) *SliceCmd
    func (c *Ring) HMSet(key string, fields map[string]interface{}) *StatusCmd
    func (c *Ring) HScan(key string, cursor uint64, match string, count int64) *ScanCmd
    func (c *Ring) HSet(key, field string, value interface{}) *BoolCmd
    func (c *Ring) HSetNX(key, field string, value interface{}) *BoolCmd
    func (c *Ring) HVals(key string) *StringSliceCmd
    func (c *Ring) Incr(key string) *IntCmd
    func (c *Ring) IncrBy(key string, value int64) *IntCmd
    func (c *Ring) IncrByFloat(key string, value float64) *FloatCmd
    func (c *Ring) Info(section ...string) *StringCmd
    func (c *Ring) Keys(pattern string) *StringSliceCmd
    func (c *Ring) LIndex(key string, index int64) *StringCmd
    func (c *Ring) LInsert(key, op string, pivot, value interface{}) *IntCmd
    func (c *Ring) LInsertAfter(key string, pivot, value interface{}) *IntCmd
    func (c *Ring) LInsertBefore(key string, pivot, value interface{}) *IntCmd
    func (c *Ring) LLen(key string) *IntCmd
    func (c *Ring) LPop(key string) *StringCmd
    func (c *Ring) LPush(key string, values ...interface{}) *IntCmd
    func (c *Ring) LPushX(key string, value interface{}) *IntCmd
    func (c *Ring) LRange(key string, start, stop int64) *StringSliceCmd
    func (c *Ring) LRem(key string, count int64, value interface{}) *IntCmd
    func (c *Ring) LSet(key string, index int64, value interface{}) *StatusCmd
    func (c *Ring) LTrim(key string, start, stop int64) *StatusCmd
    func (c *Ring) LastSave() *IntCmd
    func (c *Ring) MGet(keys ...string) *SliceCmd
    func (c *Ring) MSet(pairs ...interface{}) *StatusCmd
    func (c *Ring) MSetNX(pairs ...interface{}) *BoolCmd
    func (c *Ring) Migrate(host, port, key string, db int64, timeout time.Duration) *StatusCmd
    func (c *Ring) Move(key string, db int64) *BoolCmd
    func (c *Ring) ObjectEncoding(key string) *StringCmd
    func (c *Ring) ObjectIdleTime(key string) *DurationCmd
    func (c *Ring) ObjectRefCount(key string) *IntCmd
    func (c *Ring) Options() *RingOptions
    func (c *Ring) PExpire(key string, expiration time.Duration) *BoolCmd
    func (c *Ring) PExpireAt(key string, tm time.Time) *BoolCmd
    func (c *Ring) PFAdd(key string, els ...interface{}) *IntCmd
    func (c *Ring) PFCount(keys ...string) *IntCmd
    func (c *Ring) PFMerge(dest string, keys ...string) *StatusCmd
    func (c *Ring) PSubscribe(channels ...string) *PubSub
    func (c *Ring) PTTL(key string) *DurationCmd
    func (c *Ring) Persist(key string) *BoolCmd
    func (c *Ring) Ping() *StatusCmd
    func (c *Ring) Pipeline() Pipeliner
    func (c *Ring) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)
    func (c *Ring) PoolStats() *PoolStats
    func (c *Ring) Process(cmd Cmder) error
    func (c *Ring) PubSubChannels(pattern string) *StringSliceCmd
    func (c *Ring) PubSubNumPat() *IntCmd
    func (c *Ring) PubSubNumSub(channels ...string) *StringIntMapCmd
    func (c *Ring) Publish(channel, message string) *IntCmd
    func (c *Ring) Quit() *StatusCmd
    func (c *Ring) RPop(key string) *StringCmd
    func (c *Ring) RPopLPush(source, destination string) *StringCmd
    func (c *Ring) RPush(key string, values ...interface{}) *IntCmd
    func (c *Ring) RPushX(key string, value interface{}) *IntCmd
    func (c *Ring) RandomKey() *StringCmd
    func (c *Ring) Rename(key, newkey string) *StatusCmd
    func (c *Ring) RenameNX(key, newkey string) *BoolCmd
    func (c *Ring) Restore(key string, ttl time.Duration, value string) *StatusCmd
    func (c *Ring) RestoreReplace(key string, ttl time.Duration, value string) *StatusCmd
    func (c *Ring) SAdd(key string, members ...interface{}) *IntCmd
    func (c *Ring) SCard(key string) *IntCmd
    func (c *Ring) SDiff(keys ...string) *StringSliceCmd
    func (c *Ring) SDiffStore(destination string, keys ...string) *IntCmd
    func (c *Ring) SInter(keys ...string) *StringSliceCmd
    func (c *Ring) SInterStore(destination string, keys ...string) *IntCmd
    func (c *Ring) SIsMember(key string, member interface{}) *BoolCmd
    func (c *Ring) SMembers(key string) *StringSliceCmd
    func (c *Ring) SMove(source, destination string, member interface{}) *BoolCmd
    func (c *Ring) SPop(key string) *StringCmd
    func (c *Ring) SPopN(key string, count int64) *StringSliceCmd
    func (c *Ring) SRandMember(key string) *StringCmd
    func (c *Ring) SRandMemberN(key string, count int64) *StringSliceCmd
    func (c *Ring) SRem(key string, members ...interface{}) *IntCmd
    func (c *Ring) SScan(key string, cursor uint64, match string, count int64) *ScanCmd
    func (c *Ring) SUnion(keys ...string) *StringSliceCmd
    func (c *Ring) SUnionStore(destination string, keys ...string) *IntCmd
    func (c *Ring) Save() *StatusCmd
    func (c *Ring) Scan(cursor uint64, match string, count int64) *ScanCmd
    func (c *Ring) ScriptExists(scripts ...string) *BoolSliceCmd
    func (c *Ring) ScriptFlush() *StatusCmd
    func (c *Ring) ScriptKill() *StatusCmd
    func (c *Ring) ScriptLoad(script string) *StringCmd
    func (c *Ring) Set(key string, value interface{}, expiration time.Duration) *StatusCmd
    func (c *Ring) SetBit(key string, offset int64, value int) *IntCmd
    func (c *Ring) SetNX(key string, value interface{}, expiration time.Duration) *BoolCmd
    func (c *Ring) SetRange(key string, offset int64, value string) *IntCmd
    func (c *Ring) SetXX(key string, value interface{}, expiration time.Duration) *BoolCmd
    func (c *Ring) Shutdown() *StatusCmd
    func (c *Ring) ShutdownNoSave() *StatusCmd
    func (c *Ring) ShutdownSave() *StatusCmd
    func (c *Ring) SlaveOf(host, port string) *StatusCmd
    func (c *Ring) SlowLog()
    func (c *Ring) Sort(key string, sort Sort) *StringSliceCmd
    func (c *Ring) SortInterfaces(key string, sort Sort) *SliceCmd
    func (c *Ring) StrLen(key string) *IntCmd
    func (c *Ring) Subscribe(channels ...string) *PubSub
    func (c *Ring) Sync()
    func (c *Ring) TTL(key string) *DurationCmd
    func (c *Ring) Time() *TimeCmd
    func (c *Ring) Type(key string) *StatusCmd
    func (c *Ring) Unlink(keys ...string) *IntCmd
    func (c *Ring) Wait(numSlaves int, timeout time.Duration) *IntCmd
    func (c *Ring) ZAdd(key string, members ...Z) *IntCmd
    func (c *Ring) ZAddCh(key string, members ...Z) *IntCmd
    func (c *Ring) ZAddNX(key string, members ...Z) *IntCmd
    func (c *Ring) ZAddNXCh(key string, members ...Z) *IntCmd
    func (c *Ring) ZAddXX(key string, members ...Z) *IntCmd
    func (c *Ring) ZAddXXCh(key string, members ...Z) *IntCmd
    func (c *Ring) ZCard(key string) *IntCmd
    func (c *Ring) ZCount(key, min, max string) *IntCmd
    func (c *Ring) ZIncr(key string, member Z) *FloatCmd
    func (c *Ring) ZIncrBy(key string, increment float64, member string) *FloatCmd
    func (c *Ring) ZIncrNX(key string, member Z) *FloatCmd
    func (c *Ring) ZIncrXX(key string, member Z) *FloatCmd
    func (c *Ring) ZInterStore(destination string, store ZStore, keys ...string) *IntCmd
    func (c *Ring) ZRange(key string, start, stop int64) *StringSliceCmd
    func (c *Ring) ZRangeByLex(key string, opt ZRangeBy) *StringSliceCmd
    func (c *Ring) ZRangeByScore(key string, opt ZRangeBy) *StringSliceCmd
    func (c *Ring) ZRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd
    func (c *Ring) ZRangeWithScores(key string, start, stop int64) *ZSliceCmd
    func (c *Ring) ZRank(key, member string) *IntCmd
    func (c *Ring) ZRem(key string, members ...interface{}) *IntCmd
    func (c *Ring) ZRemRangeByLex(key, min, max string) *IntCmd
    func (c *Ring) ZRemRangeByRank(key string, start, stop int64) *IntCmd
    func (c *Ring) ZRemRangeByScore(key, min, max string) *IntCmd
    func (c *Ring) ZRevRange(key string, start, stop int64) *StringSliceCmd
    func (c *Ring) ZRevRangeByLex(key string, opt ZRangeBy) *StringSliceCmd
    func (c *Ring) ZRevRangeByScore(key string, opt ZRangeBy) *StringSliceCmd
    func (c *Ring) ZRevRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd
    func (c *Ring) ZRevRangeWithScores(key string, start, stop int64) *ZSliceCmd
    func (c *Ring) ZRevRank(key, member string) *IntCmd
    func (c *Ring) ZScan(key string, cursor uint64, match string, count int64) *ScanCmd
    func (c *Ring) ZScore(key, member string) *FloatCmd
    func (c *Ring) ZUnionStore(dest string, store ZStore, keys ...string) *IntCmd
type RingOptions
type ScanCmd
    func NewScanCmd(process func(cmd Cmder) error, args ...interface{}) *ScanCmd
    func NewScanCmdResult(keys []string, cursor uint64, err error) *ScanCmd
    func (cmd *ScanCmd) Err() error
    func (cmd *ScanCmd) Iterator() *ScanIterator
    func (cmd *ScanCmd) Name() string
    func (cmd *ScanCmd) Result() (keys []string, cursor uint64, err error)
    func (cmd *ScanCmd) String() string
    func (cmd *ScanCmd) Val() (keys []string, cursor uint64)
type ScanIterator
    func (it *ScanIterator) Err() error
    func (it *ScanIterator) Next() bool
    func (it *ScanIterator) Val() string
type Script
    func NewScript(src string) *Script
    func (s *Script) Eval(c scripter, keys []string, args ...interface{}) *Cmd
    func (s *Script) EvalSha(c scripter, keys []string, args ...interface{}) *Cmd
    func (s *Script) Exists(c scripter) *BoolSliceCmd
    func (s *Script) Hash() string
    func (s *Script) Load(c scripter) *StringCmd
    func (s *Script) Run(c scripter, keys []string, args ...interface{}) *Cmd
type SliceCmd
    func NewSliceCmd(args ...interface{}) *SliceCmd
    func NewSliceResult(val []interface{}, err error) *SliceCmd
    func (cmd *SliceCmd) Err() error
    func (cmd *SliceCmd) Name() string
    func (cmd *SliceCmd) Result() ([]interface{}, error)
    func (cmd *SliceCmd) String() string
    func (cmd *SliceCmd) Val() []interface{}
type Sort
type StatefulCmdable
type StatusCmd
    func NewStatusCmd(args ...interface{}) *StatusCmd
    func NewStatusResult(val string, err error) *StatusCmd
    func (cmd *StatusCmd) Err() error
    func (cmd *StatusCmd) Name() string
    func (cmd *StatusCmd) Result() (string, error)
    func (cmd *StatusCmd) String() string
    func (cmd *StatusCmd) Val() string
type StringCmd
    func NewStringCmd(args ...interface{}) *StringCmd
    func NewStringResult(val string, err error) *StringCmd
    func (cmd *StringCmd) Bytes() ([]byte, error)
    func (cmd *StringCmd) Err() error
    func (cmd *StringCmd) Float64() (float64, error)
    func (cmd *StringCmd) Int64() (int64, error)
    func (cmd *StringCmd) Name() string
    func (cmd *StringCmd) Result() (string, error)
    func (cmd *StringCmd) Scan(val interface{}) error
    func (cmd *StringCmd) String() string
    func (cmd *StringCmd) Uint64() (uint64, error)
    func (cmd *StringCmd) Val() string
type StringIntMapCmd
    func NewStringIntMapCmd(args ...interface{}) *StringIntMapCmd
    func NewStringIntMapCmdResult(val map[string]int64, err error) *StringIntMapCmd
    func (cmd *StringIntMapCmd) Err() error
    func (cmd *StringIntMapCmd) Name() string
    func (cmd *StringIntMapCmd) Result() (map[string]int64, error)
    func (cmd *StringIntMapCmd) String() string
    func (cmd *StringIntMapCmd) Val() map[string]int64
type StringSliceCmd
    func NewStringSliceCmd(args ...interface{}) *StringSliceCmd
    func NewStringSliceResult(val []string, err error) *StringSliceCmd
    func (cmd *StringSliceCmd) Err() error
    func (cmd *StringSliceCmd) Name() string
    func (cmd *StringSliceCmd) Result() ([]string, error)
    func (cmd *StringSliceCmd) ScanSlice(container interface{}) error
    func (cmd *StringSliceCmd) String() string
    func (cmd *StringSliceCmd) Val() []string
type StringStringMapCmd
    func NewStringStringMapCmd(args ...interface{}) *StringStringMapCmd
    func NewStringStringMapResult(val map[string]string, err error) *StringStringMapCmd
    func (cmd *StringStringMapCmd) Err() error
    func (cmd *StringStringMapCmd) Name() string
    func (cmd *StringStringMapCmd) Result() (map[string]string, error)
    func (cmd *StringStringMapCmd) String() string
    func (cmd *StringStringMapCmd) Val() map[string]string
type Subscription
    func (m *Subscription) String() string
type TimeCmd
    func NewTimeCmd(args ...interface{}) *TimeCmd
    func (cmd *TimeCmd) Err() error
    func (cmd *TimeCmd) Name() string
    func (cmd *TimeCmd) Result() (time.Time, error)
    func (cmd *TimeCmd) String() string
    func (cmd *TimeCmd) Val() time.Time
type Tx
    func (c *Tx) Auth(password string) *StatusCmd
    func (c *Tx) ClientSetName(name string) *BoolCmd
    func (c *Tx) Close() error
    func (c *Tx) Pipeline() Pipeliner
    func (c *Tx) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)
    func (c *Tx) Process(cmd Cmder) error
    func (c *Tx) ReadOnly() *StatusCmd
    func (c *Tx) ReadWrite() *StatusCmd
    func (c *Tx) Select(index int) *StatusCmd
    func (c *Tx) String() string
    func (c *Tx) Unwatch(keys ...string) *StatusCmd
    func (c *Tx) Watch(keys ...string) *StatusCmd
    func (c *Tx) WrapProcess(fn func(oldProcess func(cmd Cmder) error) func(cmd Cmder) error)
type UniversalClient
    func NewUniversalClient(opts *UniversalOptions) UniversalClient
type UniversalOptions
type Z
type ZRangeBy
type ZSliceCmd
    func NewZSliceCmd(args ...interface{}) *ZSliceCmd
    func NewZSliceCmdResult(val []Z, err error) *ZSliceCmd
    func (cmd *ZSliceCmd) Err() error
    func (cmd *ZSliceCmd) Name() string
    func (cmd *ZSliceCmd) Result() ([]Z, error)
    func (cmd *ZSliceCmd) String() string
    func (cmd *ZSliceCmd) Val() []Z
type ZStore

Package files

cluster.go command.go commands.go doc.go iterator.go options.go parser.go pipeline.go pubsub.go redis.go redis_context.go result.go ring.go script.go sentinel.go tx.go universal.go

Constants

Redis nil reply, .e.g. when key does not exist.

const Nil = internal.Nil

Redis transaction failed.

const TxFailedErr = internal.RedisError("redis: transaction failed")

func SetLogger

func SetLogger(logger *log.Logger)

type BitCount

type BitCount struct {
    Start, End int64
}

type BoolCmd

type BoolCmd struct {
    // contains filtered or unexported fields
}

func NewBoolCmd

func NewBoolCmd(args ...interface{}) *BoolCmd

func NewBoolResult

func NewBoolResult(val bool, err error) *BoolCmd

NewBoolResult returns a BoolCmd initalised with val and err for testing

func (*BoolCmd) Err

func (cmd *BoolCmd) Err() error

func (*BoolCmd) Name

func (cmd *BoolCmd) Name() string

func (*BoolCmd) Result

func (cmd *BoolCmd) Result() (bool, error)

func (*BoolCmd) String

func (cmd *BoolCmd) String() string

func (*BoolCmd) Val

func (cmd *BoolCmd) Val() bool

type BoolSliceCmd

type BoolSliceCmd struct {
    // contains filtered or unexported fields
}

func NewBoolSliceCmd

func NewBoolSliceCmd(args ...interface{}) *BoolSliceCmd

func NewBoolSliceResult

func NewBoolSliceResult(val []bool, err error) *BoolSliceCmd

NewBoolSliceResult returns a BoolSliceCmd initalised with val and err for testing

func (*BoolSliceCmd) Err

func (cmd *BoolSliceCmd) Err() error

func (*BoolSliceCmd) Name

func (cmd *BoolSliceCmd) Name() string

func (*BoolSliceCmd) Result

func (cmd *BoolSliceCmd) Result() ([]bool, error)

func (*BoolSliceCmd) String

func (cmd *BoolSliceCmd) String() string

func (*BoolSliceCmd) Val

func (cmd *BoolSliceCmd) Val() []bool

type Client

Client is a Redis client representing a pool of zero or more underlying connections. It's safe for concurrent use by multiple goroutines.

type Client struct {
    // contains filtered or unexported fields
}

Example

Code:

err := client.Set("key", "value", 0).Err()
if err != nil {
    panic(err)
}

val, err := client.Get("key").Result()
if err != nil {
    panic(err)
}
fmt.Println("key", val)

val2, err := client.Get("key2").Result()
if err == redis.Nil {
    fmt.Println("key2 does not exists")
} else if err != nil {
    panic(err)
} else {
    fmt.Println("key2", val2)
}

Output:

key value
key2 does not exists

func NewClient

func NewClient(opt *Options) *Client

NewClient returns a client to the Redis Server specified by Options.

Example

Code:

client := redis.NewClient(&redis.Options{
    Addr:     "localhost:6379",
    Password: "", // no password set
    DB:       0,  // use default DB
})

pong, err := client.Ping().Result()
fmt.Println(pong, err)

Output:

PONG <nil>

func NewFailoverClient

func NewFailoverClient(failoverOpt *FailoverOptions) *Client

NewFailoverClient returns a Redis client that uses Redis Sentinel for automatic failover. It's safe for concurrent use by multiple goroutines.

Example

Code:

// See http://redis.io/topics/sentinel for instructions how to
// setup Redis Sentinel.
client := redis.NewFailoverClient(&redis.FailoverOptions{
    MasterName:    "master",
    SentinelAddrs: []string{":26379"},
})
client.Ping()

func (*Client) Append

func (c *Client) Append(key, value string) *IntCmd

func (*Client) BLPop

func (c *Client) BLPop(timeout time.Duration, keys ...string) *StringSliceCmd

func (*Client) BRPop

func (c *Client) BRPop(timeout time.Duration, keys ...string) *StringSliceCmd

func (*Client) BRPopLPush

func (c *Client) BRPopLPush(source, destination string, timeout time.Duration) *StringCmd

func (*Client) BgRewriteAOF

func (c *Client) BgRewriteAOF() *StatusCmd

func (*Client) BgSave

func (c *Client) BgSave() *StatusCmd

func (*Client) BitCount

func (c *Client) BitCount(key string, bitCount *BitCount) *IntCmd

func (*Client) BitOpAnd

func (c *Client) BitOpAnd(destKey string, keys ...string) *IntCmd

func (*Client) BitOpNot

func (c *Client) BitOpNot(destKey string, key string) *IntCmd

func (*Client) BitOpOr

func (c *Client) BitOpOr(destKey string, keys ...string) *IntCmd

func (*Client) BitOpXor

func (c *Client) BitOpXor(destKey string, keys ...string) *IntCmd

func (*Client) BitPos

func (c *Client) BitPos(key string, bit int64, pos ...int64) *IntCmd

func (*Client) ClientGetName

func (c *Client) ClientGetName() *StringCmd

ClientGetName returns the name of the connection.

func (*Client) ClientKill

func (c *Client) ClientKill(ipPort string) *StatusCmd

func (*Client) ClientList

func (c *Client) ClientList() *StringCmd

func (*Client) ClientPause

func (c *Client) ClientPause(dur time.Duration) *BoolCmd

func (*Client) Close

func (c *Client) Close() error

Close closes the client, releasing any open resources.

It is rare to Close a Client, as the Client is meant to be long-lived and shared between many goroutines.

func (*Client) ClusterAddSlots

func (c *Client) ClusterAddSlots(slots ...int) *StatusCmd

func (*Client) ClusterAddSlotsRange

func (c *Client) ClusterAddSlotsRange(min, max int) *StatusCmd

func (*Client) ClusterCountFailureReports

func (c *Client) ClusterCountFailureReports(nodeID string) *IntCmd

func (*Client) ClusterCountKeysInSlot

func (c *Client) ClusterCountKeysInSlot(slot int) *IntCmd

func (*Client) ClusterDelSlots

func (c *Client) ClusterDelSlots(slots ...int) *StatusCmd

func (*Client) ClusterDelSlotsRange

func (c *Client) ClusterDelSlotsRange(min, max int) *StatusCmd

func (*Client) ClusterFailover

func (c *Client) ClusterFailover() *StatusCmd

func (*Client) ClusterForget

func (c *Client) ClusterForget(nodeID string) *StatusCmd

func (*Client) ClusterInfo

func (c *Client) ClusterInfo() *StringCmd

func (*Client) ClusterKeySlot

func (c *Client) ClusterKeySlot(key string) *IntCmd

func (*Client) ClusterMeet

func (c *Client) ClusterMeet(host, port string) *StatusCmd

func (*Client) ClusterNodes

func (c *Client) ClusterNodes() *StringCmd

func (*Client) ClusterReplicate

func (c *Client) ClusterReplicate(nodeID string) *StatusCmd

func (*Client) ClusterResetHard

func (c *Client) ClusterResetHard() *StatusCmd

func (*Client) ClusterResetSoft

func (c *Client) ClusterResetSoft() *StatusCmd

func (*Client) ClusterSaveConfig

func (c *Client) ClusterSaveConfig() *StatusCmd

func (*Client) ClusterSlaves

func (c *Client) ClusterSlaves(nodeID string) *StringSliceCmd

func (*Client) ClusterSlots

func (c *Client) ClusterSlots() *ClusterSlotsCmd

func (*Client) Command

func (c *Client) Command() *CommandsInfoCmd

func (*Client) ConfigGet

func (c *Client) ConfigGet(parameter string) *SliceCmd

func (*Client) ConfigResetStat

func (c *Client) ConfigResetStat() *StatusCmd

func (*Client) ConfigSet

func (c *Client) ConfigSet(parameter, value string) *StatusCmd

func (*Client) Context

func (c *Client) Context() context.Context

func (*Client) DbSize

func (c *Client) DbSize() *IntCmd

func (*Client) DebugObject

func (c *Client) DebugObject(key string) *StringCmd

func (*Client) Decr

func (c *Client) Decr(key string) *IntCmd

func (*Client) DecrBy

func (c *Client) DecrBy(key string, decrement int64) *IntCmd

func (*Client) Del

func (c *Client) Del(keys ...string) *IntCmd

func (*Client) Dump

func (c *Client) Dump(key string) *StringCmd

func (*Client) Echo

func (c *Client) Echo(message interface{}) *StringCmd

func (*Client) Eval

func (c *Client) Eval(script string, keys []string, args ...interface{}) *Cmd

func (*Client) EvalSha

func (c *Client) EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd

func (*Client) Exists

func (c *Client) Exists(keys ...string) *IntCmd

func (*Client) Expire

func (c *Client) Expire(key string, expiration time.Duration) *BoolCmd

func (*Client) ExpireAt

func (c *Client) ExpireAt(key string, tm time.Time) *BoolCmd

func (*Client) FlushAll

func (c *Client) FlushAll() *StatusCmd

func (*Client) FlushAllAsync

func (c *Client) FlushAllAsync() *StatusCmd

func (*Client) FlushDB

func (c *Client) FlushDB() *StatusCmd

func (*Client) FlushDBAsync

func (c *Client) FlushDBAsync() *StatusCmd

func (*Client) FlushDb

func (c *Client) FlushDb() *StatusCmd

Deprecated. Use FlushDB instead.

func (*Client) GeoAdd

func (c *Client) GeoAdd(key string, geoLocation ...*GeoLocation) *IntCmd

func (*Client) GeoDist

func (c *Client) GeoDist(key string, member1, member2, unit string) *FloatCmd

func (*Client) GeoHash

func (c *Client) GeoHash(key string, members ...string) *StringSliceCmd

func (*Client) GeoPos

func (c *Client) GeoPos(key string, members ...string) *GeoPosCmd

func (*Client) GeoRadius

func (c *Client) GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd

func (*Client) GeoRadiusByMember

func (c *Client) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) *GeoLocationCmd

func (*Client) Get

func (c *Client) Get(key string) *StringCmd

func (*Client) GetBit

func (c *Client) GetBit(key string, offset int64) *IntCmd

func (*Client) GetRange

func (c *Client) GetRange(key string, start, end int64) *StringCmd

func (*Client) GetSet

func (c *Client) GetSet(key string, value interface{}) *StringCmd

func (*Client) HDel

func (c *Client) HDel(key string, fields ...string) *IntCmd

func (*Client) HExists

func (c *Client) HExists(key, field string) *BoolCmd

func (*Client) HGet

func (c *Client) HGet(key, field string) *StringCmd

func (*Client) HGetAll

func (c *Client) HGetAll(key string) *StringStringMapCmd

func (*Client) HIncrBy

func (c *Client) HIncrBy(key, field string, incr int64) *IntCmd

func (*Client) HIncrByFloat

func (c *Client) HIncrByFloat(key, field string, incr float64) *FloatCmd

func (*Client) HKeys

func (c *Client) HKeys(key string) *StringSliceCmd

func (*Client) HLen

func (c *Client) HLen(key string) *IntCmd

func (*Client) HMGet

func (c *Client) HMGet(key string, fields ...string) *SliceCmd

func (*Client) HMSet

func (c *Client) HMSet(key string, fields map[string]interface{}) *StatusCmd

func (*Client) HScan

func (c *Client) HScan(key string, cursor uint64, match string, count int64) *ScanCmd

func (*Client) HSet

func (c *Client) HSet(key, field string, value interface{}) *BoolCmd

func (*Client) HSetNX

func (c *Client) HSetNX(key, field string, value interface{}) *BoolCmd

func (*Client) HVals

func (c *Client) HVals(key string) *StringSliceCmd

func (*Client) Incr

func (c *Client) Incr(key string) *IntCmd

func (*Client) IncrBy

func (c *Client) IncrBy(key string, value int64) *IntCmd

func (*Client) IncrByFloat

func (c *Client) IncrByFloat(key string, value float64) *FloatCmd

func (*Client) Info

func (c *Client) Info(section ...string) *StringCmd

func (*Client) Keys

func (c *Client) Keys(pattern string) *StringSliceCmd

func (*Client) LIndex

func (c *Client) LIndex(key string, index int64) *StringCmd

func (*Client) LInsert

func (c *Client) LInsert(key, op string, pivot, value interface{}) *IntCmd

func (*Client) LInsertAfter

func (c *Client) LInsertAfter(key string, pivot, value interface{}) *IntCmd

func (*Client) LInsertBefore

func (c *Client) LInsertBefore(key string, pivot, value interface{}) *IntCmd

func (*Client) LLen

func (c *Client) LLen(key string) *IntCmd

func (*Client) LPop

func (c *Client) LPop(key string) *StringCmd

func (*Client) LPush

func (c *Client) LPush(key string, values ...interface{}) *IntCmd

func (*Client) LPushX

func (c *Client) LPushX(key string, value interface{}) *IntCmd

func (*Client) LRange

func (c *Client) LRange(key string, start, stop int64) *StringSliceCmd

func (*Client) LRem

func (c *Client) LRem(key string, count int64, value interface{}) *IntCmd

func (*Client) LSet

func (c *Client) LSet(key string, index int64, value interface{}) *StatusCmd

func (*Client) LTrim

func (c *Client) LTrim(key string, start, stop int64) *StatusCmd

func (*Client) LastSave

func (c *Client) LastSave() *IntCmd

func (*Client) MGet

func (c *Client) MGet(keys ...string) *SliceCmd

func (*Client) MSet

func (c *Client) MSet(pairs ...interface{}) *StatusCmd

func (*Client) MSetNX

func (c *Client) MSetNX(pairs ...interface{}) *BoolCmd

func (*Client) Migrate

func (c *Client) Migrate(host, port, key string, db int64, timeout time.Duration) *StatusCmd

func (*Client) Move

func (c *Client) Move(key string, db int64) *BoolCmd

func (*Client) ObjectEncoding

func (c *Client) ObjectEncoding(key string) *StringCmd

func (*Client) ObjectIdleTime

func (c *Client) ObjectIdleTime(key string) *DurationCmd

func (*Client) ObjectRefCount

func (c *Client) ObjectRefCount(key string) *IntCmd

func (*Client) Options

func (c *Client) Options() *Options

Options returns read-only Options that were used to create the client.

func (*Client) PExpire

func (c *Client) PExpire(key string, expiration time.Duration) *BoolCmd

func (*Client) PExpireAt

func (c *Client) PExpireAt(key string, tm time.Time) *BoolCmd

func (*Client) PFAdd

func (c *Client) PFAdd(key string, els ...interface{}) *IntCmd

func (*Client) PFCount

func (c *Client) PFCount(keys ...string) *IntCmd

func (*Client) PFMerge

func (c *Client) PFMerge(dest string, keys ...string) *StatusCmd

func (*Client) PSubscribe

func (c *Client) PSubscribe(channels ...string) *PubSub

PSubscribe subscribes the client to the given patterns. Patterns can be omitted to create empty subscription.

func (*Client) PTTL

func (c *Client) PTTL(key string) *DurationCmd

func (*Client) Persist

func (c *Client) Persist(key string) *BoolCmd

func (*Client) Ping

func (c *Client) Ping() *StatusCmd

func (*Client) Pipeline

func (c *Client) Pipeline() Pipeliner

Example

Code:

pipe := client.Pipeline()

incr := pipe.Incr("pipeline_counter")
pipe.Expire("pipeline_counter", time.Hour)

// Execute
//
//     INCR pipeline_counter
//     EXPIRE pipeline_counts 3600
//
// using one client-server roundtrip.
_, err := pipe.Exec()
fmt.Println(incr.Val(), err)

Output:

1 <nil>

func (*Client) Pipelined

func (c *Client) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)

Example

Code:

var incr *redis.IntCmd
_, err := client.Pipelined(func(pipe redis.Pipeliner) error {
    incr = pipe.Incr("pipelined_counter")
    pipe.Expire("pipelined_counter", time.Hour)
    return nil
})
fmt.Println(incr.Val(), err)

Output:

1 <nil>

func (*Client) PoolStats

func (c *Client) PoolStats() *PoolStats

PoolStats returns connection pool stats.

func (*Client) Process

func (c *Client) Process(cmd Cmder) error

func (*Client) PubSubChannels

func (c *Client) PubSubChannels(pattern string) *StringSliceCmd

func (*Client) PubSubNumPat

func (c *Client) PubSubNumPat() *IntCmd

func (*Client) PubSubNumSub

func (c *Client) PubSubNumSub(channels ...string) *StringIntMapCmd

func (*Client) Publish

func (c *Client) Publish(channel, message string) *IntCmd

Publish posts the message to the channel.

func (*Client) Quit

func (c *Client) Quit() *StatusCmd

func (*Client) RPop

func (c *Client) RPop(key string) *StringCmd

func (*Client) RPopLPush

func (c *Client) RPopLPush(source, destination string) *StringCmd

func (*Client) RPush

func (c *Client) RPush(key string, values ...interface{}) *IntCmd

func (*Client) RPushX

func (c *Client) RPushX(key string, value interface{}) *IntCmd

func (*Client) RandomKey

func (c *Client) RandomKey() *StringCmd

func (*Client) Rename

func (c *Client) Rename(key, newkey string) *StatusCmd

func (*Client) RenameNX

func (c *Client) RenameNX(key, newkey string) *BoolCmd

func (*Client) Restore

func (c *Client) Restore(key string, ttl time.Duration, value string) *StatusCmd

func (*Client) RestoreReplace

func (c *Client) RestoreReplace(key string, ttl time.Duration, value string) *StatusCmd

func (*Client) SAdd

func (c *Client) SAdd(key string, members ...interface{}) *IntCmd

func (*Client) SCard

func (c *Client) SCard(key string) *IntCmd

func (*Client) SDiff

func (c *Client) SDiff(keys ...string) *StringSliceCmd

func (*Client) SDiffStore

func (c *Client) SDiffStore(destination string, keys ...string) *IntCmd

func (*Client) SInter

func (c *Client) SInter(keys ...string) *StringSliceCmd

func (*Client) SInterStore

func (c *Client) SInterStore(destination string, keys ...string) *IntCmd

func (*Client) SIsMember

func (c *Client) SIsMember(key string, member interface{}) *BoolCmd

func (*Client) SMembers

func (c *Client) SMembers(key string) *StringSliceCmd

func (*Client) SMove

func (c *Client) SMove(source, destination string, member interface{}) *BoolCmd

func (*Client) SPop

func (c *Client) SPop(key string) *StringCmd

Redis `SPOP key` command.

func (*Client) SPopN

func (c *Client) SPopN(key string, count int64) *StringSliceCmd

Redis `SPOP key count` command.

func (*Client) SRandMember

func (c *Client) SRandMember(key string) *StringCmd

Redis `SRANDMEMBER key` command.

func (*Client) SRandMemberN

func (c *Client) SRandMemberN(key string, count int64) *StringSliceCmd

Redis `SRANDMEMBER key count` command.

func (*Client) SRem

func (c *Client) SRem(key string, members ...interface{}) *IntCmd

func (*Client) SScan

func (c *Client) SScan(key string, cursor uint64, match string, count int64) *ScanCmd

func (*Client) SUnion

func (c *Client) SUnion(keys ...string) *StringSliceCmd

func (*Client) SUnionStore

func (c *Client) SUnionStore(destination string, keys ...string) *IntCmd

func (*Client) Save

func (c *Client) Save() *StatusCmd

func (*Client) Scan

func (c *Client) Scan(cursor uint64, match string, count int64) *ScanCmd

func (*Client) ScriptExists

func (c *Client) ScriptExists(scripts ...string) *BoolSliceCmd

func (*Client) ScriptFlush

func (c *Client) ScriptFlush() *StatusCmd

func (*Client) ScriptKill

func (c *Client) ScriptKill() *StatusCmd

func (*Client) ScriptLoad

func (c *Client) ScriptLoad(script string) *StringCmd

func (*Client) Set

func (c *Client) Set(key string, value interface{}, expiration time.Duration) *StatusCmd

Redis `SET key value [expiration]` command.

Use expiration for `SETEX`-like behavior. Zero expiration means the key has no expiration time.

func (*Client) SetBit

func (c *Client) SetBit(key string, offset int64, value int) *IntCmd

func (*Client) SetNX

func (c *Client) SetNX(key string, value interface{}, expiration time.Duration) *BoolCmd

Redis `SET key value [expiration] NX` command.

Zero expiration means the key has no expiration time.

func (*Client) SetRange

func (c *Client) SetRange(key string, offset int64, value string) *IntCmd

func (*Client) SetXX

func (c *Client) SetXX(key string, value interface{}, expiration time.Duration) *BoolCmd

Redis `SET key value [expiration] XX` command.

Zero expiration means the key has no expiration time.

func (*Client) Shutdown

func (c *Client) Shutdown() *StatusCmd

func (*Client) ShutdownNoSave

func (c *Client) ShutdownNoSave() *StatusCmd

func (*Client) ShutdownSave

func (c *Client) ShutdownSave() *StatusCmd

func (*Client) SlaveOf

func (c *Client) SlaveOf(host, port string) *StatusCmd

func (*Client) SlowLog

func (c *Client) SlowLog()

func (*Client) Sort

func (c *Client) Sort(key string, sort Sort) *StringSliceCmd

func (*Client) SortInterfaces

func (c *Client) SortInterfaces(key string, sort Sort) *SliceCmd

func (*Client) StrLen

func (c *Client) StrLen(key string) *IntCmd

func (*Client) String

func (c *Client) String() string

func (*Client) Subscribe

func (c *Client) Subscribe(channels ...string) *PubSub

Subscribe subscribes the client to the specified channels. Channels can be omitted to create empty subscription.

func (*Client) Sync

func (c *Client) Sync()

func (*Client) TTL

func (c *Client) TTL(key string) *DurationCmd

func (*Client) Time

func (c *Client) Time() *TimeCmd

func (*Client) TxPipeline

func (c *Client) TxPipeline() Pipeliner

TxPipeline acts like Pipeline, but wraps queued commands with MULTI/EXEC.

Example

Code:

pipe := client.TxPipeline()

incr := pipe.Incr("tx_pipeline_counter")
pipe.Expire("tx_pipeline_counter", time.Hour)

// Execute
//
//     MULTI
//     INCR pipeline_counter
//     EXPIRE pipeline_counts 3600
//     EXEC
//
// using one client-server roundtrip.
_, err := pipe.Exec()
fmt.Println(incr.Val(), err)

Output:

1 <nil>

func (*Client) TxPipelined

func (c *Client) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error)

Example

Code:

var incr *redis.IntCmd
_, err := client.TxPipelined(func(pipe redis.Pipeliner) error {
    incr = pipe.Incr("tx_pipelined_counter")
    pipe.Expire("tx_pipelined_counter", time.Hour)
    return nil
})
fmt.Println(incr.Val(), err)

Output:

1 <nil>

func (*Client) Type

func (c *Client) Type(key string) *StatusCmd
func (c *Client) Unlink(keys ...string) *IntCmd

func (*Client) Wait

func (c *Client) Wait(numSlaves int, timeout time.Duration) *IntCmd

func (*Client) Watch

func (c *Client) Watch(fn func(*Tx) error, keys ...string) error

Example

Code:

var incr func(string) error

// Transactionally increments key using GET and SET commands.
incr = func(key string) error {
    err := client.Watch(func(tx *redis.Tx) error {
        n, err := tx.Get(key).Int64()
        if err != nil && err != redis.Nil {
            return err
        }

        _, err = tx.Pipelined(func(pipe redis.Pipeliner) error {
            pipe.Set(key, strconv.FormatInt(n+1, 10), 0)
            return nil
        })
        return err
    }, key)
    if err == redis.TxFailedErr {
        return incr(key)
    }
    return err
}

var wg sync.WaitGroup
for i := 0; i < 100; i++ {
    wg.Add(1)
    go func() {
        defer wg.Done()

        err := incr("counter3")
        if err != nil {
            panic(err)
        }
    }()
}
wg.Wait()

n, err := client.Get("counter3").Int64()
fmt.Println(n, err)

Output:

100 <nil>

func (*Client) WithContext

func (c *Client) WithContext(ctx context.Context) *Client

func (*Client) WrapProcess

func (c *Client) WrapProcess(fn func(oldProcess func(cmd Cmder) error) func(cmd Cmder) error)

WrapProcess replaces the process func. It takes a function createWrapper which is supplied by the user. createWrapper takes the old process func as an input and returns the new wrapper process func. createWrapper should use call the old process func within the new process func.

func (*Client) ZAdd

func (c *Client) ZAdd(key string, members ...Z) *IntCmd

Redis `ZADD key score member [score member ...]` command.

func (*Client) ZAddCh

func (c *Client) ZAddCh(key string, members ...Z) *IntCmd

Redis `ZADD key CH score member [score member ...]` command.

func (*Client) ZAddNX

func (c *Client) ZAddNX(key string, members ...Z) *IntCmd

Redis `ZADD key NX score member [score member ...]` command.

func (*Client) ZAddNXCh

func (c *Client) ZAddNXCh(key string, members ...Z) *IntCmd

Redis `ZADD key NX CH score member [score member ...]` command.

func (*Client) ZAddXX

func (c *Client) ZAddXX(key string, members ...Z) *IntCmd

Redis `ZADD key XX score member [score member ...]` command.

func (*Client) ZAddXXCh

func (c *Client) ZAddXXCh(key string, members ...Z) *IntCmd

Redis `ZADD key XX CH score member [score member ...]` command.

func (*Client) ZCard

func (c *Client) ZCard(key string) *IntCmd

func (*Client) ZCount

func (c *Client) ZCount(key, min, max string) *IntCmd

func (*Client) ZIncr

func (c *Client) ZIncr(key string, member Z) *FloatCmd

Redis `ZADD key INCR score member` command.

func (*Client) ZIncrBy

func (c *Client) ZIncrBy(key string, increment float64, member string) *FloatCmd

func (*Client) ZIncrNX

func (c *Client) ZIncrNX(key string, member Z) *FloatCmd

Redis `ZADD key NX INCR score member` command.

func (*Client) ZIncrXX

func (c *Client) ZIncrXX(key string, member Z) *FloatCmd

Redis `ZADD key XX INCR score member` command.

func (*Client) ZInterStore

func (c *Client) ZInterStore(destination string, store ZStore, keys ...string) *IntCmd

func (*Client) ZRange

func (c *Client) ZRange(key string, start, stop int64) *StringSliceCmd

func (*Client) ZRangeByLex

func (c *Client) ZRangeByLex(key string, opt ZRangeBy) *StringSliceCmd

func (*Client) ZRangeByScore

func (c *Client) ZRangeByScore(key string, opt ZRangeBy) *StringSliceCmd

func (*Client) ZRangeByScoreWithScores

func (c *Client) ZRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd

func (*Client) ZRangeWithScores

func (c *Client) ZRangeWithScores(key string, start, stop int64) *ZSliceCmd

func (*Client) ZRank

func (c *Client) ZRank(key, member string) *IntCmd

func (*Client) ZRem

func (c *Client) ZRem(key string, members ...interface{}) *IntCmd

func (*Client) ZRemRangeByLex

func (c *Client) ZRemRangeByLex(key, min, max string) *IntCmd

func (*Client) ZRemRangeByRank

func (c *Client) ZRemRangeByRank(key string, start, stop int64) *IntCmd

func (*Client) ZRemRangeByScore

func (c *Client) ZRemRangeByScore(key, min, max string) *IntCmd

func (*Client) ZRevRange

func (c *Client) ZRevRange(key string, start, stop int64) *StringSliceCmd

func (*Client) ZRevRangeByLex

func (c *Client) ZRevRangeByLex(key string, opt ZRangeBy) *StringSliceCmd

func (*Client) ZRevRangeByScore

func (c *Client) ZRevRangeByScore(key string, opt ZRangeBy) *StringSliceCmd

func (*Client) ZRevRangeByScoreWithScores

func (c *Client) ZRevRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd

func (*Client) ZRevRangeWithScores

func (c *Client) ZRevRangeWithScores(key string, start, stop int64) *ZSliceCmd

func (*Client) ZRevRank

func (c *Client) ZRevRank(key, member string) *IntCmd

func (*Client) ZScan

func (c *Client) ZScan(key string, cursor uint64, match string, count int64) *ScanCmd

func (*Client) ZScore

func (c *Client) ZScore(key, member string) *FloatCmd

func (*Client) ZUnionStore

func (c *Client) ZUnionStore(dest string, store ZStore, keys ...string) *IntCmd

type ClusterClient

ClusterClient is a Redis Cluster client representing a pool of zero or more underlying connections. It's safe for concurrent use by multiple goroutines.

type ClusterClient struct {
    // contains filtered or unexported fields
}

func NewClusterClient

func NewClusterClient(opt *ClusterOptions) *ClusterClient

NewClusterClient returns a Redis Cluster client as described in http://redis.io/topics/cluster-spec.

Example

Code:

// See http://redis.io/topics/cluster-tutorial for instructions
// how to setup Redis Cluster.
client := redis.NewClusterClient(&redis.ClusterOptions{
    Addrs: []string{":7000", ":7001", ":7002", ":7003", ":7004", ":7005"},
})
client.Ping()

func (*ClusterClient) Append

func (c *ClusterClient) Append(key, value string) *IntCmd

func (*ClusterClient) BLPop

func (c *ClusterClient) BLPop(timeout time.Duration, keys ...string) *StringSliceCmd

func (*ClusterClient) BRPop

func (c *ClusterClient) BRPop(timeout time.Duration, keys ...string) *StringSliceCmd

func (*ClusterClient) BRPopLPush

func (c *ClusterClient) BRPopLPush(source, destination string, timeout time.Duration) *StringCmd

func (*ClusterClient) BgRewriteAOF

func (c *ClusterClient) BgRewriteAOF() *StatusCmd

func (*ClusterClient) BgSave

func (c *ClusterClient) BgSave() *StatusCmd

func (*ClusterClient) BitCount

func (c *ClusterClient) BitCount(key string, bitCount *BitCount) *IntCmd

func (*ClusterClient) BitOpAnd

func (c *ClusterClient) BitOpAnd(destKey string, keys ...string) *IntCmd

func (*ClusterClient) BitOpNot

func (c *ClusterClient) BitOpNot(destKey string, key string) *IntCmd

func (*ClusterClient) BitOpOr

func (c *ClusterClient) BitOpOr(destKey string, keys ...string) *IntCmd

func (*ClusterClient) BitOpXor

func (c *ClusterClient) BitOpXor(destKey string, keys ...string) *IntCmd

func (*ClusterClient) BitPos

func (c *ClusterClient) BitPos(key string, bit int64, pos ...int64) *IntCmd

func (*ClusterClient) ClientGetName

func (c *ClusterClient) ClientGetName() *StringCmd

ClientGetName returns the name of the connection.

func (*ClusterClient) ClientKill

func (c *ClusterClient) ClientKill(ipPort string) *StatusCmd

func (*ClusterClient) ClientList

func (c *ClusterClient) ClientList() *StringCmd

func (*ClusterClient) ClientPause

func (c *ClusterClient) ClientPause(dur time.Duration) *BoolCmd

func (*ClusterClient) Close

func (c *ClusterClient) Close() error

Close closes the cluster client, releasing any open resources.

It is rare to Close a ClusterClient, as the ClusterClient is meant to be long-lived and shared between many goroutines.

func (*ClusterClient) ClusterAddSlots

func (c *ClusterClient) ClusterAddSlots(slots ...int) *StatusCmd

func (*ClusterClient) ClusterAddSlotsRange

func (c *ClusterClient) ClusterAddSlotsRange(min, max int) *StatusCmd

func (*ClusterClient) ClusterCountFailureReports

func (c *ClusterClient) ClusterCountFailureReports(nodeID string) *IntCmd

func (*ClusterClient) ClusterCountKeysInSlot

func (c *ClusterClient) ClusterCountKeysInSlot(slot int) *IntCmd

func (*ClusterClient) ClusterDelSlots

func (c *ClusterClient) ClusterDelSlots(slots ...int) *StatusCmd

func (*ClusterClient) ClusterDelSlotsRange

func (c *ClusterClient) ClusterDelSlotsRange(min, max int) *StatusCmd

func (*ClusterClient) ClusterFailover

func (c *ClusterClient) ClusterFailover() *StatusCmd

func (*ClusterClient) ClusterForget

func (c *ClusterClient) ClusterForget(nodeID string) *StatusCmd

func (*ClusterClient) ClusterInfo

func (c *ClusterClient) ClusterInfo() *StringCmd

func (*ClusterClient) ClusterKeySlot

func (c *ClusterClient) ClusterKeySlot(key string) *IntCmd

func (*ClusterClient) ClusterMeet

func (c *ClusterClient) ClusterMeet(host, port string) *StatusCmd

func (*ClusterClient) ClusterNodes

func (c *ClusterClient) ClusterNodes() *StringCmd

func (*ClusterClient) ClusterReplicate

func (c *ClusterClient) ClusterReplicate(nodeID string) *StatusCmd

func (*ClusterClient) ClusterResetHard

func (c *ClusterClient) ClusterResetHard() *StatusCmd

func (*ClusterClient) ClusterResetSoft

func (c *ClusterClient) ClusterResetSoft() *StatusCmd

func (*ClusterClient) ClusterSaveConfig

func (c *ClusterClient) ClusterSaveConfig() *StatusCmd

func (*ClusterClient) ClusterSlaves

func (c *ClusterClient) ClusterSlaves(nodeID string) *StringSliceCmd

func (*ClusterClient) ClusterSlots

func (c *ClusterClient) ClusterSlots() *ClusterSlotsCmd

func (*ClusterClient) Command

func (c *ClusterClient) Command() *CommandsInfoCmd

func (*ClusterClient) ConfigGet

func (c *ClusterClient) ConfigGet(parameter string) *SliceCmd

func (*ClusterClient) ConfigResetStat

func (c *ClusterClient) ConfigResetStat() *StatusCmd

func (*ClusterClient) ConfigSet

func (c *ClusterClient) ConfigSet(parameter, value string) *StatusCmd

func (*ClusterClient) DbSize

func (c *ClusterClient) DbSize() *IntCmd

func (*ClusterClient) DebugObject

func (c *ClusterClient) DebugObject(key string) *StringCmd

func (*ClusterClient) Decr

func (c *ClusterClient) Decr(key string) *IntCmd

func (*ClusterClient) DecrBy

func (c *ClusterClient) DecrBy(key string, decrement int64) *IntCmd

func (*ClusterClient) Del

func (c *ClusterClient) Del(keys ...string) *IntCmd

func (*ClusterClient) Dump

func (c *ClusterClient) Dump(key string) *StringCmd

func (*ClusterClient) Echo

func (c *ClusterClient) Echo(message interface{}) *StringCmd

func (*ClusterClient) Eval

func (c *ClusterClient) Eval(script string, keys []string, args ...interface{}) *Cmd

func (*ClusterClient) EvalSha

func (c *ClusterClient) EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd

func (*ClusterClient) Exists

func (c *ClusterClient) Exists(keys ...string) *IntCmd

func (*ClusterClient) Expire

func (c *ClusterClient) Expire(key string, expiration time.Duration) *BoolCmd

func (*ClusterClient) ExpireAt

func (c *ClusterClient) ExpireAt(key string, tm time.Time) *BoolCmd

func (*ClusterClient) FlushAll

func (c *ClusterClient) FlushAll() *StatusCmd

func (*ClusterClient) FlushAllAsync

func (c *ClusterClient) FlushAllAsync() *StatusCmd

func (*ClusterClient) FlushDB

func (c *ClusterClient) FlushDB() *StatusCmd

func (*ClusterClient) FlushDBAsync

func (c *ClusterClient) FlushDBAsync() *StatusCmd

func (*ClusterClient) FlushDb

func (c *ClusterClient) FlushDb() *StatusCmd

Deprecated. Use FlushDB instead.

func (*ClusterClient) ForEachMaster

func (c *ClusterClient) ForEachMaster(fn func(client *Client) error) error

ForEachMaster concurrently calls the fn on each master node in the cluster. It returns the first error if any.

func (*ClusterClient) ForEachNode

func (c *ClusterClient) ForEachNode(fn func(client *Client) error) error

ForEachNode concurrently calls the fn on each ever known node in the cluster. It returns the first error if any.

func (*ClusterClient) GeoAdd

func (c *ClusterClient) GeoAdd(key string, geoLocation ...*GeoLocation) *IntCmd

func (*ClusterClient) GeoDist

func (c *ClusterClient) GeoDist(key string, member1, member2, unit string) *FloatCmd

func (*ClusterClient) GeoHash

func (c *ClusterClient) GeoHash(key string, members ...string) *StringSliceCmd

func (*ClusterClient) GeoPos

func (c *ClusterClient) GeoPos(key string, members ...string) *GeoPosCmd

func (*ClusterClient) GeoRadius

func (c *ClusterClient) GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd

func (*ClusterClient) GeoRadiusByMember

func (c *ClusterClient) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) *GeoLocationCmd

func (*ClusterClient) Get

func (c *ClusterClient) Get(key string) *StringCmd

func (*ClusterClient) GetBit

func (c *ClusterClient) GetBit(key string, offset int64) *IntCmd

func (*ClusterClient) GetRange

func (c *ClusterClient) GetRange(key string, start, end int64) *StringCmd

func (*ClusterClient) GetSet

func (c *ClusterClient) GetSet(key string, value interface{}) *StringCmd

func (*ClusterClient) HDel

func (c *ClusterClient) HDel(key string, fields ...string) *IntCmd

func (*ClusterClient) HExists

func (c *ClusterClient) HExists(key, field string) *BoolCmd

func (*ClusterClient) HGet

func (c *ClusterClient) HGet(key, field string) *StringCmd

func (*ClusterClient) HGetAll

func (c *ClusterClient) HGetAll(key string) *StringStringMapCmd

func (*ClusterClient) HIncrBy

func (c *ClusterClient) HIncrBy(key, field string, incr int64) *IntCmd

func (*ClusterClient) HIncrByFloat

func (c *ClusterClient) HIncrByFloat(key, field string, incr float64) *FloatCmd

func (*ClusterClient) HKeys

func (c *ClusterClient) HKeys(key string) *StringSliceCmd

func (*ClusterClient) HLen

func (c *ClusterClient) HLen(key string) *IntCmd

func (*ClusterClient) HMGet

func (c *ClusterClient) HMGet(key string, fields ...string) *SliceCmd

func (*ClusterClient) HMSet

func (c *ClusterClient) HMSet(key string, fields map[string]interface{}) *StatusCmd

func (*ClusterClient) HScan

func (c *ClusterClient) HScan(key string, cursor uint64, match string, count int64) *ScanCmd

func (*ClusterClient) HSet

func (c *ClusterClient) HSet(key, field string, value interface{}) *BoolCmd

func (*ClusterClient) HSetNX

func (c *ClusterClient) HSetNX(key, field string, value interface{}) *BoolCmd

func (*ClusterClient) HVals

func (c *ClusterClient) HVals(key string) *StringSliceCmd

func (*ClusterClient) Incr

func (c *ClusterClient) Incr(key string) *IntCmd

func (*ClusterClient) IncrBy

func (c *ClusterClient) IncrBy(key string, value int64) *IntCmd

func (*ClusterClient) IncrByFloat

func (c *ClusterClient) IncrByFloat(key string, value float64) *FloatCmd

func (*ClusterClient) Info

func (c *ClusterClient) Info(section ...string) *StringCmd

func (*ClusterClient) Keys

func (c *ClusterClient) Keys(pattern string) *StringSliceCmd

func (*ClusterClient) LIndex

func (c *ClusterClient) LIndex(key string, index int64) *StringCmd

func (*ClusterClient) LInsert

func (c *ClusterClient) LInsert(key, op string, pivot, value interface{}) *IntCmd

func (*ClusterClient) LInsertAfter

func (c *ClusterClient) LInsertAfter(key string, pivot, value interface{}) *IntCmd

func (*ClusterClient) LInsertBefore

func (c *ClusterClient) LInsertBefore(key string, pivot, value interface{}) *IntCmd

func (*ClusterClient) LLen

func (c *ClusterClient) LLen(key string) *IntCmd

func (*ClusterClient) LPop

func (c *ClusterClient) LPop(key string) *StringCmd

func (*ClusterClient) LPush

func (c *ClusterClient) LPush(key string, values ...interface{}) *IntCmd

func (*ClusterClient) LPushX

func (c *ClusterClient) LPushX(key string, value interface{}) *IntCmd

func (*ClusterClient) LRange

func (c *ClusterClient) LRange(key string, start, stop int64) *StringSliceCmd

func (*ClusterClient) LRem

func (c *ClusterClient) LRem(key string, count int64, value interface{}) *IntCmd

func (*ClusterClient) LSet

func (c *ClusterClient) LSet(key string, index int64, value interface{}) *StatusCmd

func (*ClusterClient) LTrim

func (c *ClusterClient) LTrim(key string, start, stop int64) *StatusCmd

func (*ClusterClient) LastSave

func (c *ClusterClient) LastSave() *IntCmd

func (*ClusterClient) MGet

func (c *ClusterClient) MGet(keys ...string) *SliceCmd

func (*ClusterClient) MSet

func (c *ClusterClient) MSet(pairs ...interface{}) *StatusCmd

func (*ClusterClient) MSetNX

func (c *ClusterClient) MSetNX(pairs ...interface{}) *BoolCmd

func (*ClusterClient) Migrate

func (c *ClusterClient) Migrate(host, port, key string, db int64, timeout time.Duration) *StatusCmd

func (*ClusterClient) Move

func (c *ClusterClient) Move(key string, db int64) *BoolCmd

func (*ClusterClient) ObjectEncoding

func (c *ClusterClient) ObjectEncoding(key string) *StringCmd

func (*ClusterClient) ObjectIdleTime

func (c *ClusterClient) ObjectIdleTime(key string) *DurationCmd

func (*ClusterClient) ObjectRefCount

func (c *ClusterClient) ObjectRefCount(key string) *IntCmd

func (*ClusterClient) Options

func (c *ClusterClient) Options() *ClusterOptions

Options returns read-only Options that were used to create the client.

func (*ClusterClient) PExpire

func (c *ClusterClient) PExpire(key string, expiration time.Duration) *BoolCmd

func (*ClusterClient) PExpireAt

func (c *ClusterClient) PExpireAt(key string, tm time.Time) *BoolCmd

func (*ClusterClient) PFAdd

func (c *ClusterClient) PFAdd(key string, els ...interface{}) *IntCmd

func (*ClusterClient) PFCount

func (c *ClusterClient) PFCount(keys ...string) *IntCmd

func (*ClusterClient) PFMerge

func (c *ClusterClient) PFMerge(dest string, keys ...string) *StatusCmd

func (*ClusterClient) PTTL

func (c *ClusterClient) PTTL(key string) *DurationCmd

func (*ClusterClient) Persist

func (c *ClusterClient) Persist(key string) *BoolCmd

func (*ClusterClient) Ping

func (c *ClusterClient) Ping() *StatusCmd

func (*ClusterClient) Pipeline

func (c *ClusterClient) Pipeline() Pipeliner

func (*ClusterClient) Pipelined

func (c *ClusterClient) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)

func (*ClusterClient) PoolStats

func (c *ClusterClient) PoolStats() *PoolStats

PoolStats returns accumulated connection pool stats.

func (*ClusterClient) Process

func (c *ClusterClient) Process(cmd Cmder) error

func (*ClusterClient) PubSubChannels

func (c *ClusterClient) PubSubChannels(pattern string) *StringSliceCmd

func (*ClusterClient) PubSubNumPat

func (c *ClusterClient) PubSubNumPat() *IntCmd

func (*ClusterClient) PubSubNumSub

func (c *ClusterClient) PubSubNumSub(channels ...string) *StringIntMapCmd

func (*ClusterClient) Publish

func (c *ClusterClient) Publish(channel, message string) *IntCmd

Publish posts the message to the channel.

func (*ClusterClient) Quit

func (c *ClusterClient) Quit() *StatusCmd

func (*ClusterClient) RPop

func (c *ClusterClient) RPop(key string) *StringCmd

func (*ClusterClient) RPopLPush

func (c *ClusterClient) RPopLPush(source, destination string) *StringCmd

func (*ClusterClient) RPush

func (c *ClusterClient) RPush(key string, values ...interface{}) *IntCmd

func (*ClusterClient) RPushX

func (c *ClusterClient) RPushX(key string, value interface{}) *IntCmd

func (*ClusterClient) RandomKey

func (c *ClusterClient) RandomKey() *StringCmd

func (*ClusterClient) Rename

func (c *ClusterClient) Rename(key, newkey string) *StatusCmd

func (*ClusterClient) RenameNX

func (c *ClusterClient) RenameNX(key, newkey string) *BoolCmd

func (*ClusterClient) Restore

func (c *ClusterClient) Restore(key string, ttl time.Duration, value string) *StatusCmd

func (*ClusterClient) RestoreReplace

func (c *ClusterClient) RestoreReplace(key string, ttl time.Duration, value string) *StatusCmd

func (*ClusterClient) SAdd

func (c *ClusterClient) SAdd(key string, members ...interface{}) *IntCmd

func (*ClusterClient) SCard

func (c *ClusterClient) SCard(key string) *IntCmd

func (*ClusterClient) SDiff

func (c *ClusterClient) SDiff(keys ...string) *StringSliceCmd

func (*ClusterClient) SDiffStore

func (c *ClusterClient) SDiffStore(destination string, keys ...string) *IntCmd

func (*ClusterClient) SInter

func (c *ClusterClient) SInter(keys ...string) *StringSliceCmd

func (*ClusterClient) SInterStore

func (c *ClusterClient) SInterStore(destination string, keys ...string) *IntCmd

func (*ClusterClient) SIsMember

func (c *ClusterClient) SIsMember(key string, member interface{}) *BoolCmd

func (*ClusterClient) SMembers

func (c *ClusterClient) SMembers(key string) *StringSliceCmd

func (*ClusterClient) SMove

func (c *ClusterClient) SMove(source, destination string, member interface{}) *BoolCmd

func (*ClusterClient) SPop

func (c *ClusterClient) SPop(key string) *StringCmd

Redis `SPOP key` command.

func (*ClusterClient) SPopN

func (c *ClusterClient) SPopN(key string, count int64) *StringSliceCmd

Redis `SPOP key count` command.

func (*ClusterClient) SRandMember

func (c *ClusterClient) SRandMember(key string) *StringCmd

Redis `SRANDMEMBER key` command.

func (*ClusterClient) SRandMemberN

func (c *ClusterClient) SRandMemberN(key string, count int64) *StringSliceCmd

Redis `SRANDMEMBER key count` command.

func (*ClusterClient) SRem

func (c *ClusterClient) SRem(key string, members ...interface{}) *IntCmd

func (*ClusterClient) SScan

func (c *ClusterClient) SScan(key string, cursor uint64, match string, count int64) *ScanCmd

func (*ClusterClient) SUnion

func (c *ClusterClient) SUnion(keys ...string) *StringSliceCmd

func (*ClusterClient) SUnionStore

func (c *ClusterClient) SUnionStore(destination string, keys ...string) *IntCmd

func (*ClusterClient) Save

func (c *ClusterClient) Save() *StatusCmd

func (*ClusterClient) Scan

func (c *ClusterClient) Scan(cursor uint64, match string, count int64) *ScanCmd

func (*ClusterClient) ScriptExists

func (c *ClusterClient) ScriptExists(scripts ...string) *BoolSliceCmd

func (*ClusterClient) ScriptFlush

func (c *ClusterClient) ScriptFlush() *StatusCmd

func (*ClusterClient) ScriptKill

func (c *ClusterClient) ScriptKill() *StatusCmd

func (*ClusterClient) ScriptLoad

func (c *ClusterClient) ScriptLoad(script string) *StringCmd

func (*ClusterClient) Set

func (c *ClusterClient) Set(key string, value interface{}, expiration time.Duration) *StatusCmd

Redis `SET key value [expiration]` command.

Use expiration for `SETEX`-like behavior. Zero expiration means the key has no expiration time.

func (*ClusterClient) SetBit

func (c *ClusterClient) SetBit(key string, offset int64, value int) *IntCmd

func (*ClusterClient) SetNX

func (c *ClusterClient) SetNX(key string, value interface{}, expiration time.Duration) *BoolCmd

Redis `SET key value [expiration] NX` command.

Zero expiration means the key has no expiration time.

func (*ClusterClient) SetRange

func (c *ClusterClient) SetRange(key string, offset int64, value string) *IntCmd

func (*ClusterClient) SetXX

func (c *ClusterClient) SetXX(key string, value interface{}, expiration time.Duration) *BoolCmd

Redis `SET key value [expiration] XX` command.

Zero expiration means the key has no expiration time.

func (*ClusterClient) Shutdown

func (c *ClusterClient) Shutdown() *StatusCmd

func (*ClusterClient) ShutdownNoSave

func (c *ClusterClient) ShutdownNoSave() *StatusCmd

func (*ClusterClient) ShutdownSave

func (c *ClusterClient) ShutdownSave() *StatusCmd

func (*ClusterClient) SlaveOf

func (c *ClusterClient) SlaveOf(host, port string) *StatusCmd

func (*ClusterClient) SlowLog

func (c *ClusterClient) SlowLog()

func (*ClusterClient) Sort

func (c *ClusterClient) Sort(key string, sort Sort) *StringSliceCmd

func (*ClusterClient) SortInterfaces

func (c *ClusterClient) SortInterfaces(key string, sort Sort) *SliceCmd

func (*ClusterClient) StrLen

func (c *ClusterClient) StrLen(key string) *IntCmd

func (*ClusterClient) Sync

func (c *ClusterClient) Sync()

func (*ClusterClient) TTL

func (c *ClusterClient) TTL(key string) *DurationCmd

func (*ClusterClient) Time

func (c *ClusterClient) Time() *TimeCmd

func (*ClusterClient) TxPipeline

func (c *ClusterClient) TxPipeline() Pipeliner

TxPipeline acts like Pipeline, but wraps queued commands with MULTI/EXEC.

func (*ClusterClient) TxPipelined

func (c *ClusterClient) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error)

func (*ClusterClient) Type

func (c *ClusterClient) Type(key string) *StatusCmd
func (c *ClusterClient) Unlink(keys ...string) *IntCmd

func (*ClusterClient) Wait

func (c *ClusterClient) Wait(numSlaves int, timeout time.Duration) *IntCmd

func (*ClusterClient) Watch

func (c *ClusterClient) Watch(fn func(*Tx) error, keys ...string) error

func (*ClusterClient) ZAdd

func (c *ClusterClient) ZAdd(key string, members ...Z) *IntCmd

Redis `ZADD key score member [score member ...]` command.

func (*ClusterClient) ZAddCh

func (c *ClusterClient) ZAddCh(key string, members ...Z) *IntCmd

Redis `ZADD key CH score member [score member ...]` command.

func (*ClusterClient) ZAddNX

func (c *ClusterClient) ZAddNX(key string, members ...Z) *IntCmd

Redis `ZADD key NX score member [score member ...]` command.

func (*ClusterClient) ZAddNXCh

func (c *ClusterClient) ZAddNXCh(key string, members ...Z) *IntCmd

Redis `ZADD key NX CH score member [score member ...]` command.

func (*ClusterClient) ZAddXX

func (c *ClusterClient) ZAddXX(key string, members ...Z) *IntCmd

Redis `ZADD key XX score member [score member ...]` command.

func (*ClusterClient) ZAddXXCh

func (c *ClusterClient) ZAddXXCh(key string, members ...Z) *IntCmd

Redis `ZADD key XX CH score member [score member ...]` command.

func (*ClusterClient) ZCard

func (c *ClusterClient) ZCard(key string) *IntCmd

func (*ClusterClient) ZCount

func (c *ClusterClient) ZCount(key, min, max string) *IntCmd

func (*ClusterClient) ZIncr

func (c *ClusterClient) ZIncr(key string, member Z) *FloatCmd

Redis `ZADD key INCR score member` command.

func (*ClusterClient) ZIncrBy

func (c *ClusterClient) ZIncrBy(key string, increment float64, member string) *FloatCmd

func (*ClusterClient) ZIncrNX

func (c *ClusterClient) ZIncrNX(key string, member Z) *FloatCmd

Redis `ZADD key NX INCR score member` command.

func (*ClusterClient) ZIncrXX

func (c *ClusterClient) ZIncrXX(key string, member Z) *FloatCmd

Redis `ZADD key XX INCR score member` command.

func (*ClusterClient) ZInterStore

func (c *ClusterClient) ZInterStore(destination string, store ZStore, keys ...string) *IntCmd

func (*ClusterClient) ZRange

func (c *ClusterClient) ZRange(key string, start, stop int64) *StringSliceCmd

func (*ClusterClient) ZRangeByLex

func (c *ClusterClient) ZRangeByLex(key string, opt ZRangeBy) *StringSliceCmd

func (*ClusterClient) ZRangeByScore

func (c *ClusterClient) ZRangeByScore(key string, opt ZRangeBy) *StringSliceCmd

func (*ClusterClient) ZRangeByScoreWithScores

func (c *ClusterClient) ZRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd

func (*ClusterClient) ZRangeWithScores

func (c *ClusterClient) ZRangeWithScores(key string, start, stop int64) *ZSliceCmd

func (*ClusterClient) ZRank

func (c *ClusterClient) ZRank(key, member string) *IntCmd

func (*ClusterClient) ZRem

func (c *ClusterClient) ZRem(key string, members ...interface{}) *IntCmd

func (*ClusterClient) ZRemRangeByLex

func (c *ClusterClient) ZRemRangeByLex(key, min, max string) *IntCmd

func (*ClusterClient) ZRemRangeByRank

func (c *ClusterClient) ZRemRangeByRank(key string, start, stop int64) *IntCmd

func (*ClusterClient) ZRemRangeByScore

func (c *ClusterClient) ZRemRangeByScore(key, min, max string) *IntCmd

func (*ClusterClient) ZRevRange

func (c *ClusterClient) ZRevRange(key string, start, stop int64) *StringSliceCmd

func (*ClusterClient) ZRevRangeByLex

func (c *ClusterClient) ZRevRangeByLex(key string, opt ZRangeBy) *StringSliceCmd

func (*ClusterClient) ZRevRangeByScore

func (c *ClusterClient) ZRevRangeByScore(key string, opt ZRangeBy) *StringSliceCmd

func (*ClusterClient) ZRevRangeByScoreWithScores

func (c *ClusterClient) ZRevRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd

func (*ClusterClient) ZRevRangeWithScores

func (c *ClusterClient) ZRevRangeWithScores(key string, start, stop int64) *ZSliceCmd

func (*ClusterClient) ZRevRank

func (c *ClusterClient) ZRevRank(key, member string) *IntCmd

func (*ClusterClient) ZScan

func (c *ClusterClient) ZScan(key string, cursor uint64, match string, count int64) *ScanCmd

func (*ClusterClient) ZScore

func (c *ClusterClient) ZScore(key, member string) *FloatCmd

func (*ClusterClient) ZUnionStore

func (c *ClusterClient) ZUnionStore(dest string, store ZStore, keys ...string) *IntCmd

type ClusterNode

type ClusterNode struct {
    Id   string
    Addr string
}

type ClusterOptions

ClusterOptions are used to configure a cluster client and should be passed to NewClusterClient.

type ClusterOptions struct {
    // A seed list of host:port addresses of cluster nodes.
    Addrs []string

    // The maximum number of retries before giving up. Command is retried
    // on network errors and MOVED/ASK redirects.
    // Default is 16.
    MaxRedirects int

    // Enables read queries for a connection to a Redis Cluster slave node.
    ReadOnly bool

    // Enables routing read-only queries to the closest master or slave node.
    RouteByLatency bool

    OnConnect func(*Conn) error

    MaxRetries int
    Password   string

    DialTimeout  time.Duration
    ReadTimeout  time.Duration
    WriteTimeout time.Duration

    // PoolSize applies per cluster node and not for the whole cluster.
    PoolSize           int
    PoolTimeout        time.Duration
    IdleTimeout        time.Duration
    IdleCheckFrequency time.Duration
}

type ClusterSlot

type ClusterSlot struct {
    Start int
    End   int
    Nodes []ClusterNode
}

type ClusterSlotsCmd

type ClusterSlotsCmd struct {
    // contains filtered or unexported fields
}

func NewClusterSlotsCmd

func NewClusterSlotsCmd(args ...interface{}) *ClusterSlotsCmd

func NewClusterSlotsCmdResult

func NewClusterSlotsCmdResult(val []ClusterSlot, err error) *ClusterSlotsCmd

NewClusterSlotsCmdResult returns a ClusterSlotsCmd initalised with val and err for testing

func (*ClusterSlotsCmd) Err

func (cmd *ClusterSlotsCmd) Err() error

func (*ClusterSlotsCmd) Name

func (cmd *ClusterSlotsCmd) Name() string

func (*ClusterSlotsCmd) Result

func (cmd *ClusterSlotsCmd) Result() ([]ClusterSlot, error)

func (*ClusterSlotsCmd) String

func (cmd *ClusterSlotsCmd) String() string

func (*ClusterSlotsCmd) Val

func (cmd *ClusterSlotsCmd) Val() []ClusterSlot

type Cmd

type Cmd struct {
    // contains filtered or unexported fields
}

func NewCmd

func NewCmd(args ...interface{}) *Cmd

func NewCmdResult

func NewCmdResult(val interface{}, err error) *Cmd

NewCmdResult returns a Cmd initalised with val and err for testing

func (*Cmd) Err

func (cmd *Cmd) Err() error

func (*Cmd) Name

func (cmd *Cmd) Name() string

func (*Cmd) Result

func (cmd *Cmd) Result() (interface{}, error)

func (*Cmd) String

func (cmd *Cmd) String() string

func (*Cmd) Val

func (cmd *Cmd) Val() interface{}

type Cmdable

type Cmdable interface {
    Pipeline() Pipeliner
    Pipelined(fn func(Pipeliner) error) ([]Cmder, error)

    ClientGetName() *StringCmd
    Echo(message interface{}) *StringCmd
    Ping() *StatusCmd
    Quit() *StatusCmd
    Del(keys ...string) *IntCmd
    Unlink(keys ...string) *IntCmd
    Dump(key string) *StringCmd
    Exists(keys ...string) *IntCmd
    Expire(key string, expiration time.Duration) *BoolCmd
    ExpireAt(key string, tm time.Time) *BoolCmd
    Keys(pattern string) *StringSliceCmd
    Migrate(host, port, key string, db int64, timeout time.Duration) *StatusCmd
    Move(key string, db int64) *BoolCmd
    ObjectRefCount(key string) *IntCmd
    ObjectEncoding(key string) *StringCmd
    ObjectIdleTime(key string) *DurationCmd
    Persist(key string) *BoolCmd
    PExpire(key string, expiration time.Duration) *BoolCmd
    PExpireAt(key string, tm time.Time) *BoolCmd
    PTTL(key string) *DurationCmd
    RandomKey() *StringCmd
    Rename(key, newkey string) *StatusCmd
    RenameNX(key, newkey string) *BoolCmd
    Restore(key string, ttl time.Duration, value string) *StatusCmd
    RestoreReplace(key string, ttl time.Duration, value string) *StatusCmd
    Sort(key string, sort Sort) *StringSliceCmd
    SortInterfaces(key string, sort Sort) *SliceCmd
    TTL(key string) *DurationCmd
    Type(key string) *StatusCmd
    Scan(cursor uint64, match string, count int64) *ScanCmd
    SScan(key string, cursor uint64, match string, count int64) *ScanCmd
    HScan(key string, cursor uint64, match string, count int64) *ScanCmd
    ZScan(key string, cursor uint64, match string, count int64) *ScanCmd
    Append(key, value string) *IntCmd
    BitCount(key string, bitCount *BitCount) *IntCmd
    BitOpAnd(destKey string, keys ...string) *IntCmd
    BitOpOr(destKey string, keys ...string) *IntCmd
    BitOpXor(destKey string, keys ...string) *IntCmd
    BitOpNot(destKey string, key string) *IntCmd
    BitPos(key string, bit int64, pos ...int64) *IntCmd
    Decr(key string) *IntCmd
    DecrBy(key string, decrement int64) *IntCmd
    Get(key string) *StringCmd
    GetBit(key string, offset int64) *IntCmd
    GetRange(key string, start, end int64) *StringCmd
    GetSet(key string, value interface{}) *StringCmd
    Incr(key string) *IntCmd
    IncrBy(key string, value int64) *IntCmd
    IncrByFloat(key string, value float64) *FloatCmd
    MGet(keys ...string) *SliceCmd
    MSet(pairs ...interface{}) *StatusCmd
    MSetNX(pairs ...interface{}) *BoolCmd
    Set(key string, value interface{}, expiration time.Duration) *StatusCmd
    SetBit(key string, offset int64, value int) *IntCmd
    SetNX(key string, value interface{}, expiration time.Duration) *BoolCmd
    SetXX(key string, value interface{}, expiration time.Duration) *BoolCmd
    SetRange(key string, offset int64, value string) *IntCmd
    StrLen(key string) *IntCmd
    HDel(key string, fields ...string) *IntCmd
    HExists(key, field string) *BoolCmd
    HGet(key, field string) *StringCmd
    HGetAll(key string) *StringStringMapCmd
    HIncrBy(key, field string, incr int64) *IntCmd
    HIncrByFloat(key, field string, incr float64) *FloatCmd
    HKeys(key string) *StringSliceCmd
    HLen(key string) *IntCmd
    HMGet(key string, fields ...string) *SliceCmd
    HMSet(key string, fields map[string]interface{}) *StatusCmd
    HSet(key, field string, value interface{}) *BoolCmd
    HSetNX(key, field string, value interface{}) *BoolCmd
    HVals(key string) *StringSliceCmd
    BLPop(timeout time.Duration, keys ...string) *StringSliceCmd
    BRPop(timeout time.Duration, keys ...string) *StringSliceCmd
    BRPopLPush(source, destination string, timeout time.Duration) *StringCmd
    LIndex(key string, index int64) *StringCmd
    LInsert(key, op string, pivot, value interface{}) *IntCmd
    LInsertBefore(key string, pivot, value interface{}) *IntCmd
    LInsertAfter(key string, pivot, value interface{}) *IntCmd
    LLen(key string) *IntCmd
    LPop(key string) *StringCmd
    LPush(key string, values ...interface{}) *IntCmd
    LPushX(key string, value interface{}) *IntCmd
    LRange(key string, start, stop int64) *StringSliceCmd
    LRem(key string, count int64, value interface{}) *IntCmd
    LSet(key string, index int64, value interface{}) *StatusCmd
    LTrim(key string, start, stop int64) *StatusCmd
    RPop(key string) *StringCmd
    RPopLPush(source, destination string) *StringCmd
    RPush(key string, values ...interface{}) *IntCmd
    RPushX(key string, value interface{}) *IntCmd
    SAdd(key string, members ...interface{}) *IntCmd
    SCard(key string) *IntCmd
    SDiff(keys ...string) *StringSliceCmd
    SDiffStore(destination string, keys ...string) *IntCmd
    SInter(keys ...string) *StringSliceCmd
    SInterStore(destination string, keys ...string) *IntCmd
    SIsMember(key string, member interface{}) *BoolCmd
    SMembers(key string) *StringSliceCmd
    SMove(source, destination string, member interface{}) *BoolCmd
    SPop(key string) *StringCmd
    SPopN(key string, count int64) *StringSliceCmd
    SRandMember(key string) *StringCmd
    SRandMemberN(key string, count int64) *StringSliceCmd
    SRem(key string, members ...interface{}) *IntCmd
    SUnion(keys ...string) *StringSliceCmd
    SUnionStore(destination string, keys ...string) *IntCmd
    ZAdd(key string, members ...Z) *IntCmd
    ZAddNX(key string, members ...Z) *IntCmd
    ZAddXX(key string, members ...Z) *IntCmd
    ZAddCh(key string, members ...Z) *IntCmd
    ZAddNXCh(key string, members ...Z) *IntCmd
    ZAddXXCh(key string, members ...Z) *IntCmd
    ZIncr(key string, member Z) *FloatCmd
    ZIncrNX(key string, member Z) *FloatCmd
    ZIncrXX(key string, member Z) *FloatCmd
    ZCard(key string) *IntCmd
    ZCount(key, min, max string) *IntCmd
    ZIncrBy(key string, increment float64, member string) *FloatCmd
    ZInterStore(destination string, store ZStore, keys ...string) *IntCmd
    ZRange(key string, start, stop int64) *StringSliceCmd
    ZRangeWithScores(key string, start, stop int64) *ZSliceCmd
    ZRangeByScore(key string, opt ZRangeBy) *StringSliceCmd
    ZRangeByLex(key string, opt ZRangeBy) *StringSliceCmd
    ZRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd
    ZRank(key, member string) *IntCmd
    ZRem(key string, members ...interface{}) *IntCmd
    ZRemRangeByRank(key string, start, stop int64) *IntCmd
    ZRemRangeByScore(key, min, max string) *IntCmd
    ZRemRangeByLex(key, min, max string) *IntCmd
    ZRevRange(key string, start, stop int64) *StringSliceCmd
    ZRevRangeWithScores(key string, start, stop int64) *ZSliceCmd
    ZRevRangeByScore(key string, opt ZRangeBy) *StringSliceCmd
    ZRevRangeByLex(key string, opt ZRangeBy) *StringSliceCmd
    ZRevRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd
    ZRevRank(key, member string) *IntCmd
    ZScore(key, member string) *FloatCmd
    ZUnionStore(dest string, store ZStore, keys ...string) *IntCmd
    PFAdd(key string, els ...interface{}) *IntCmd
    PFCount(keys ...string) *IntCmd
    PFMerge(dest string, keys ...string) *StatusCmd
    BgRewriteAOF() *StatusCmd
    BgSave() *StatusCmd
    ClientKill(ipPort string) *StatusCmd
    ClientList() *StringCmd
    ClientPause(dur time.Duration) *BoolCmd
    ConfigGet(parameter string) *SliceCmd
    ConfigResetStat() *StatusCmd
    ConfigSet(parameter, value string) *StatusCmd
    DbSize() *IntCmd
    FlushAll() *StatusCmd
    FlushAllAsync() *StatusCmd
    FlushDB() *StatusCmd
    FlushDBAsync() *StatusCmd
    Info(section ...string) *StringCmd
    LastSave() *IntCmd
    Save() *StatusCmd
    Shutdown() *StatusCmd
    ShutdownSave() *StatusCmd
    ShutdownNoSave() *StatusCmd
    SlaveOf(host, port string) *StatusCmd
    Time() *TimeCmd
    Eval(script string, keys []string, args ...interface{}) *Cmd
    EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd
    ScriptExists(scripts ...string) *BoolSliceCmd
    ScriptFlush() *StatusCmd
    ScriptKill() *StatusCmd
    ScriptLoad(script string) *StringCmd
    DebugObject(key string) *StringCmd
    PubSubChannels(pattern string) *StringSliceCmd
    PubSubNumSub(channels ...string) *StringIntMapCmd
    PubSubNumPat() *IntCmd
    ClusterSlots() *ClusterSlotsCmd
    ClusterNodes() *StringCmd
    ClusterMeet(host, port string) *StatusCmd
    ClusterForget(nodeID string) *StatusCmd
    ClusterReplicate(nodeID string) *StatusCmd
    ClusterResetSoft() *StatusCmd
    ClusterResetHard() *StatusCmd
    ClusterInfo() *StringCmd
    ClusterKeySlot(key string) *IntCmd
    ClusterCountFailureReports(nodeID string) *IntCmd
    ClusterCountKeysInSlot(slot int) *IntCmd
    ClusterDelSlots(slots ...int) *StatusCmd
    ClusterDelSlotsRange(min, max int) *StatusCmd
    ClusterSaveConfig() *StatusCmd
    ClusterSlaves(nodeID string) *StringSliceCmd
    ClusterFailover() *StatusCmd
    ClusterAddSlots(slots ...int) *StatusCmd
    ClusterAddSlotsRange(min, max int) *StatusCmd
    GeoAdd(key string, geoLocation ...*GeoLocation) *IntCmd
    GeoPos(key string, members ...string) *GeoPosCmd
    GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd
    GeoRadiusByMember(key, member string, query *GeoRadiusQuery) *GeoLocationCmd
    GeoDist(key string, member1, member2, unit string) *FloatCmd
    GeoHash(key string, members ...string) *StringSliceCmd
    Command() *CommandsInfoCmd
}

type Cmder

type Cmder interface {
    Name() string

    Err() error
    fmt.Stringer
    // contains filtered or unexported methods
}

type CommandInfo

type CommandInfo struct {
    Name        string
    Arity       int8
    Flags       []string
    FirstKeyPos int8
    LastKeyPos  int8
    StepCount   int8
    ReadOnly    bool
}

type CommandsInfoCmd

type CommandsInfoCmd struct {
    // contains filtered or unexported fields
}

func NewCommandsInfoCmd

func NewCommandsInfoCmd(args ...interface{}) *CommandsInfoCmd

func NewCommandsInfoCmdResult

func NewCommandsInfoCmdResult(val map[string]*CommandInfo, err error) *CommandsInfoCmd

NewCommandsInfoCmdResult returns a CommandsInfoCmd initalised with val and err for testing

func (*CommandsInfoCmd) Err

func (cmd *CommandsInfoCmd) Err() error

func (*CommandsInfoCmd) Name

func (cmd *CommandsInfoCmd) Name() string

func (*CommandsInfoCmd) Result

func (cmd *CommandsInfoCmd) Result() (map[string]*CommandInfo, error)

func (*CommandsInfoCmd) String

func (cmd *CommandsInfoCmd) String() string

func (*CommandsInfoCmd) Val

func (cmd *CommandsInfoCmd) Val() map[string]*CommandInfo

type Conn

Conn is like Client, but its pool contains single connection.

type Conn struct {
    // contains filtered or unexported fields
}

func (*Conn) Auth

func (c *Conn) Auth(password string) *StatusCmd

func (*Conn) ClientSetName

func (c *Conn) ClientSetName(name string) *BoolCmd

ClientSetName assigns a name to the connection.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the client, releasing any open resources.

It is rare to Close a Client, as the Client is meant to be long-lived and shared between many goroutines.

func (*Conn) Pipeline

func (c *Conn) Pipeline() Pipeliner

func (*Conn) Pipelined

func (c *Conn) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)

func (*Conn) Process

func (c *Conn) Process(cmd Cmder) error

func (*Conn) ReadOnly

func (c *Conn) ReadOnly() *StatusCmd

func (*Conn) ReadWrite

func (c *Conn) ReadWrite() *StatusCmd

func (*Conn) Select

func (c *Conn) Select(index int) *StatusCmd

func (*Conn) String

func (c *Conn) String() string

func (*Conn) TxPipeline

func (c *Conn) TxPipeline() Pipeliner

TxPipeline acts like Pipeline, but wraps queued commands with MULTI/EXEC.

func (*Conn) TxPipelined

func (c *Conn) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error)

func (*Conn) WrapProcess

func (c *Conn) WrapProcess(fn func(oldProcess func(cmd Cmder) error) func(cmd Cmder) error)

WrapProcess replaces the process func. It takes a function createWrapper which is supplied by the user. createWrapper takes the old process func as an input and returns the new wrapper process func. createWrapper should use call the old process func within the new process func.

type DurationCmd

type DurationCmd struct {
    // contains filtered or unexported fields
}

func NewDurationCmd

func NewDurationCmd(precision time.Duration, args ...interface{}) *DurationCmd

func NewDurationResult

func NewDurationResult(val time.Duration, err error) *DurationCmd

NewDurationResult returns a DurationCmd initalised with val and err for testing

func (*DurationCmd) Err

func (cmd *DurationCmd) Err() error

func (*DurationCmd) Name

func (cmd *DurationCmd) Name() string

func (*DurationCmd) Result

func (cmd *DurationCmd) Result() (time.Duration, error)

func (*DurationCmd) String

func (cmd *DurationCmd) String() string

func (*DurationCmd) Val

func (cmd *DurationCmd) Val() time.Duration

type FailoverOptions

FailoverOptions are used to configure a failover client and should be passed to NewFailoverClient.

type FailoverOptions struct {
    // The master name.
    MasterName string
    // A seed list of host:port addresses of sentinel nodes.
    SentinelAddrs []string

    OnConnect func(*Conn) error

    Password string
    DB       int

    MaxRetries int

    DialTimeout  time.Duration
    ReadTimeout  time.Duration
    WriteTimeout time.Duration

    PoolSize           int
    PoolTimeout        time.Duration
    IdleTimeout        time.Duration
    IdleCheckFrequency time.Duration
}

type FloatCmd

type FloatCmd struct {
    // contains filtered or unexported fields
}

func NewFloatCmd

func NewFloatCmd(args ...interface{}) *FloatCmd

func NewFloatResult

func NewFloatResult(val float64, err error) *FloatCmd

NewFloatResult returns a FloatCmd initalised with val and err for testing

func (*FloatCmd) Err

func (cmd *FloatCmd) Err() error

func (*FloatCmd) Name

func (cmd *FloatCmd) Name() string

func (*FloatCmd) Result

func (cmd *FloatCmd) Result() (float64, error)

func (*FloatCmd) String

func (cmd *FloatCmd) String() string

func (*FloatCmd) Val

func (cmd *FloatCmd) Val() float64

type GeoLocation

GeoLocation is used with GeoAdd to add geospatial location.

type GeoLocation struct {
    Name                      string
    Longitude, Latitude, Dist float64
    GeoHash                   int64
}

type GeoLocationCmd

type GeoLocationCmd struct {
    // contains filtered or unexported fields
}

func NewGeoLocationCmd

func NewGeoLocationCmd(q *GeoRadiusQuery, args ...interface{}) *GeoLocationCmd

func NewGeoLocationCmdResult

func NewGeoLocationCmdResult(val []GeoLocation, err error) *GeoLocationCmd

NewGeoLocationCmdResult returns a GeoLocationCmd initalised with val and err for testing

func (*GeoLocationCmd) Err

func (cmd *GeoLocationCmd) Err() error

func (*GeoLocationCmd) Name

func (cmd *GeoLocationCmd) Name() string

func (*GeoLocationCmd) Result

func (cmd *GeoLocationCmd) Result() ([]GeoLocation, error)

func (*GeoLocationCmd) String

func (cmd *GeoLocationCmd) String() string

func (*GeoLocationCmd) Val

func (cmd *GeoLocationCmd) Val() []GeoLocation

type GeoPos

type GeoPos struct {
    Longitude, Latitude float64
}

type GeoPosCmd

type GeoPosCmd struct {
    // contains filtered or unexported fields
}

func NewGeoPosCmd

func NewGeoPosCmd(args ...interface{}) *GeoPosCmd

func (*GeoPosCmd) Err

func (cmd *GeoPosCmd) Err() error

func (*GeoPosCmd) Name

func (cmd *GeoPosCmd) Name() string

func (*GeoPosCmd) Result

func (cmd *GeoPosCmd) Result() ([]*GeoPos, error)

func (*GeoPosCmd) String

func (cmd *GeoPosCmd) String() string

func (*GeoPosCmd) Val

func (cmd *GeoPosCmd) Val() []*GeoPos

type GeoRadiusQuery

GeoRadiusQuery is used with GeoRadius to query geospatial index.

type GeoRadiusQuery struct {
    Radius float64
    // Can be m, km, ft, or mi. Default is km.
    Unit        string
    WithCoord   bool
    WithDist    bool
    WithGeoHash bool
    Count       int
    // Can be ASC or DESC. Default is no sort order.
    Sort string
}

type IntCmd

type IntCmd struct {
    // contains filtered or unexported fields
}

func NewIntCmd

func NewIntCmd(args ...interface{}) *IntCmd

func NewIntResult

func NewIntResult(val int64, err error) *IntCmd

NewIntResult returns an IntCmd initalised with val and err for testing

func (*IntCmd) Err

func (cmd *IntCmd) Err() error

func (*IntCmd) Name

func (cmd *IntCmd) Name() string

func (*IntCmd) Result

func (cmd *IntCmd) Result() (int64, error)

func (*IntCmd) String

func (cmd *IntCmd) String() string

func (*IntCmd) Val

func (cmd *IntCmd) Val() int64

type Message

Message received as result of a PUBLISH command issued by another client.

type Message struct {
    Channel string
    Pattern string
    Payload string
}

func (*Message) String

func (m *Message) String() string

type Options

type Options struct {
    // The network type, either tcp or unix.
    // Default is tcp.
    Network string
    // host:port address.
    Addr string

    // Dialer creates new network connection and has priority over
    // Network and Addr options.
    Dialer func() (net.Conn, error)

    // Hook that is called when new connection is established.
    OnConnect func(*Conn) error

    // Optional password. Must match the password specified in the
    // requirepass server configuration option.
    Password string
    // Database to be selected after connecting to the server.
    DB int

    // Maximum number of retries before giving up.
    // Default is to not retry failed commands.
    MaxRetries int

    // Maximum backoff between each retry.
    // Default is 512 seconds; -1 disables backoff.
    MaxRetryBackoff time.Duration

    // Dial timeout for establishing new connections.
    // Default is 5 seconds.
    DialTimeout time.Duration
    // Timeout for socket reads. If reached, commands will fail
    // with a timeout instead of blocking.
    // Default is 3 seconds.
    ReadTimeout time.Duration
    // Timeout for socket writes. If reached, commands will fail
    // with a timeout instead of blocking.
    // Default is ReadTimeout.
    WriteTimeout time.Duration

    // Maximum number of socket connections.
    // Default is 10 connections.
    PoolSize int
    // Amount of time client waits for connection if all connections
    // are busy before returning an error.
    // Default is ReadTimeout + 1 second.
    PoolTimeout time.Duration
    // Amount of time after which client closes idle connections.
    // Should be less than server's timeout.
    // Default is 5 minutes.
    IdleTimeout time.Duration
    // Frequency of idle checks.
    // Default is 1 minute.
    // When minus value is set, then idle check is disabled.
    IdleCheckFrequency time.Duration

    // Enables read only queries on slave nodes.
    ReadOnly bool

    // TLS Config to use. When set TLS will be negotiated.
    TLSConfig *tls.Config
}

func ParseURL

func ParseURL(redisURL string) (*Options, error)

ParseURL parses an URL into Options that can be used to connect to Redis.

Example

Code:

opt, err := redis.ParseURL("redis://:qwerty@localhost:6379/1")
if err != nil {
    panic(err)
}
fmt.Println("addr is", opt.Addr)
fmt.Println("db is", opt.DB)
fmt.Println("password is", opt.Password)

// Create client as usually.
_ = redis.NewClient(opt)

Output:

addr is localhost:6379
db is 1
password is qwerty

type Pipeline

Pipeline implements pipelining as described in http://redis.io/topics/pipelining. It's safe for concurrent use by multiple goroutines.

type Pipeline struct {
    // contains filtered or unexported fields
}

func (*Pipeline) Auth

func (c *Pipeline) Auth(password string) *StatusCmd

func (*Pipeline) ClientSetName

func (c *Pipeline) ClientSetName(name string) *BoolCmd

ClientSetName assigns a name to the connection.

func (*Pipeline) Close

func (c *Pipeline) Close() error

Close closes the pipeline, releasing any open resources.

func (*Pipeline) Discard

func (c *Pipeline) Discard() error

Discard resets the pipeline and discards queued commands.

func (*Pipeline) Exec

func (c *Pipeline) Exec() ([]Cmder, error)

Exec executes all previously queued commands using one client-server roundtrip.

Exec always returns list of commands and error of the first failed command if any.

func (*Pipeline) Pipeline

func (c *Pipeline) Pipeline() Pipeliner

func (*Pipeline) Pipelined

func (c *Pipeline) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)

func (*Pipeline) Process

func (c *Pipeline) Process(cmd Cmder) error

func (*Pipeline) ReadOnly

func (c *Pipeline) ReadOnly() *StatusCmd

func (*Pipeline) ReadWrite

func (c *Pipeline) ReadWrite() *StatusCmd

func (*Pipeline) Select

func (c *Pipeline) Select(index int) *StatusCmd

type Pipeliner

type Pipeliner interface {
    StatefulCmdable
    Process(cmd Cmder) error
    Close() error
    Discard() error

    Exec() ([]Cmder, error)
    // contains filtered or unexported methods
}

type Pong

Pong received as result of a PING command issued by another client.

type Pong struct {
    Payload string
}

func (*Pong) String

func (p *Pong) String() string

type PoolStats

PoolStats contains pool state information and accumulated stats.

type PoolStats struct {
    Requests uint32 // number of times a connection was requested by the pool
    Hits     uint32 // number of times free connection was found in the pool
    Timeouts uint32 // number of times a wait timeout occurred

    TotalConns uint32 // the number of total connections in the pool
    FreeConns  uint32 // the number of free connections in the pool
}

type PubSub

PubSub implements Pub/Sub commands as described in http://redis.io/topics/pubsub. It's NOT safe for concurrent use by multiple goroutines.

PubSub automatically resubscribes to the channels and patterns when Redis becomes unavailable.

type PubSub struct {
    // contains filtered or unexported fields
}

Example

Code:

pubsub := client.Subscribe("mychannel1")
defer pubsub.Close()

err := client.Publish("mychannel1", "hello").Err()
if err != nil {
    panic(err)
}

msg, err := pubsub.ReceiveMessage()
if err != nil {
    panic(err)
}

fmt.Println(msg.Channel, msg.Payload)

Output:

mychannel1 hello

func (*PubSub) Channel

func (c *PubSub) Channel() <-chan *Message

Channel returns a channel for concurrently receiving messages. The channel is closed with PubSub.

func (*PubSub) Close

func (c *PubSub) Close() error

func (*PubSub) PSubscribe

func (c *PubSub) PSubscribe(patterns ...string) error

Subscribes the client to the given patterns. It returns empty subscription if there are no patterns.

func (*PubSub) PUnsubscribe

func (c *PubSub) PUnsubscribe(patterns ...string) error

Unsubscribes the client from the given patterns, or from all of them if none is given.

func (*PubSub) Ping

func (c *PubSub) Ping(payload ...string) error

func (*PubSub) Receive

func (c *PubSub) Receive() (interface{}, error)

Receive returns a message as a Subscription, Message, Pong or error. See PubSub example for details. This is low-level API and most clients should use ReceiveMessage.

Example

Code:

pubsub := client.Subscribe("mychannel2")
defer pubsub.Close()

n, err := client.Publish("mychannel2", "hello").Result()
if err != nil {
    panic(err)
}
fmt.Println(n, "clients received message")

for i := 0; i < 2; i++ {
    // ReceiveTimeout is a low level API. Use ReceiveMessage instead.
    msgi, err := pubsub.ReceiveTimeout(5 * time.Second)
    if err != nil {
        break
    }

    switch msg := msgi.(type) {
    case *redis.Subscription:
        fmt.Println("subscribed to", msg.Channel)
    case *redis.Message:
        fmt.Println("received", msg.Payload, "from", msg.Channel)
    default:
        panic(fmt.Errorf("unknown message: %#v", msgi))
    }
}

Output:

1 clients received message
subscribed to mychannel2
received hello from mychannel2

func (*PubSub) ReceiveMessage

func (c *PubSub) ReceiveMessage() (*Message, error)

ReceiveMessage returns a Message or error ignoring Subscription or Pong messages. It automatically reconnects to Redis Server and resubscribes to channels in case of network errors.

func (*PubSub) ReceiveTimeout

func (c *PubSub) ReceiveTimeout(timeout time.Duration) (interface{}, error)

ReceiveTimeout acts like Receive but returns an error if message is not received in time. This is low-level API and most clients should use ReceiveMessage.

func (*PubSub) Subscribe

func (c *PubSub) Subscribe(channels ...string) error

Subscribes the client to the specified channels. It returns empty subscription if there are no channels.

func (*PubSub) Unsubscribe

func (c *PubSub) Unsubscribe(channels ...string) error

Unsubscribes the client from the given channels, or from all of them if none is given.

type Ring

Ring is a Redis client that uses constistent hashing to distribute keys across multiple Redis servers (shards). It's safe for concurrent use by multiple goroutines.

Ring monitors the state of each shard and removes dead shards from the ring. When shard comes online it is added back to the ring. This gives you maximum availability and partition tolerance, but no consistency between different shards or even clients. Each client uses shards that are available to the client and does not do any coordination when shard state is changed.

Ring should be used when you need multiple Redis servers for caching and can tolerate losing data when one of the servers dies. Otherwise you should use Redis Cluster.

type Ring struct {
    // contains filtered or unexported fields
}

func NewRing

func NewRing(opt *RingOptions) *Ring

Example

Code:

client := redis.NewRing(&redis.RingOptions{
    Addrs: map[string]string{
        "shard1": ":7000",
        "shard2": ":7001",
        "shard3": ":7002",
    },
})
client.Ping()

func (*Ring) Append

func (c *Ring) Append(key, value string) *IntCmd

func (*Ring) BLPop

func (c *Ring) BLPop(timeout time.Duration, keys ...string) *StringSliceCmd

func (*Ring) BRPop

func (c *Ring) BRPop(timeout time.Duration, keys ...string) *StringSliceCmd

func (*Ring) BRPopLPush

func (c *Ring) BRPopLPush(source, destination string, timeout time.Duration) *StringCmd

func (*Ring) BgRewriteAOF

func (c *Ring) BgRewriteAOF() *StatusCmd

func (*Ring) BgSave

func (c *Ring) BgSave() *StatusCmd

func (*Ring) BitCount

func (c *Ring) BitCount(key string, bitCount *BitCount) *IntCmd

func (*Ring) BitOpAnd

func (c *Ring) BitOpAnd(destKey string, keys ...string) *IntCmd

func (*Ring) BitOpNot

func (c *Ring) BitOpNot(destKey string, key string) *IntCmd

func (*Ring) BitOpOr

func (c *Ring) BitOpOr(destKey string, keys ...string) *IntCmd

func (*Ring) BitOpXor

func (c *Ring) BitOpXor(destKey string, keys ...string) *IntCmd

func (*Ring) BitPos

func (c *Ring) BitPos(key string, bit int64, pos ...int64) *IntCmd

func (*Ring) ClientGetName

func (c *Ring) ClientGetName() *StringCmd

ClientGetName returns the name of the connection.

func (*Ring) ClientKill

func (c *Ring) ClientKill(ipPort string) *StatusCmd

func (*Ring) ClientList

func (c *Ring) ClientList() *StringCmd

func (*Ring) ClientPause

func (c *Ring) ClientPause(dur time.Duration) *BoolCmd

func (*Ring) Close

func (c *Ring) Close() error

Close closes the ring client, releasing any open resources.

It is rare to Close a Ring, as the Ring is meant to be long-lived and shared between many goroutines.

func (*Ring) ClusterAddSlots

func (c *Ring) ClusterAddSlots(slots ...int) *StatusCmd

func (*Ring) ClusterAddSlotsRange

func (c *Ring) ClusterAddSlotsRange(min, max int) *StatusCmd

func (*Ring) ClusterCountFailureReports

func (c *Ring) ClusterCountFailureReports(nodeID string) *IntCmd

func (*Ring) ClusterCountKeysInSlot

func (c *Ring) ClusterCountKeysInSlot(slot int) *IntCmd

func (*Ring) ClusterDelSlots

func (c *Ring) ClusterDelSlots(slots ...int) *StatusCmd

func (*Ring) ClusterDelSlotsRange

func (c *Ring) ClusterDelSlotsRange(min, max int) *StatusCmd

func (*Ring) ClusterFailover

func (c *Ring) ClusterFailover() *StatusCmd

func (*Ring) ClusterForget

func (c *Ring) ClusterForget(nodeID string) *StatusCmd

func (*Ring) ClusterInfo

func (c *Ring) ClusterInfo() *StringCmd

func (*Ring) ClusterKeySlot

func (c *Ring) ClusterKeySlot(key string) *IntCmd

func (*Ring) ClusterMeet

func (c *Ring) ClusterMeet(host, port string) *StatusCmd

func (*Ring) ClusterNodes

func (c *Ring) ClusterNodes() *StringCmd

func (*Ring) ClusterReplicate

func (c *Ring) ClusterReplicate(nodeID string) *StatusCmd

func (*Ring) ClusterResetHard

func (c *Ring) ClusterResetHard() *StatusCmd

func (*Ring) ClusterResetSoft

func (c *Ring) ClusterResetSoft() *StatusCmd

func (*Ring) ClusterSaveConfig

func (c *Ring) ClusterSaveConfig() *StatusCmd

func (*Ring) ClusterSlaves

func (c *Ring) ClusterSlaves(nodeID string) *StringSliceCmd

func (*Ring) ClusterSlots

func (c *Ring) ClusterSlots() *ClusterSlotsCmd

func (*Ring) Command

func (c *Ring) Command() *CommandsInfoCmd

func (*Ring) ConfigGet

func (c *Ring) ConfigGet(parameter string) *SliceCmd

func (*Ring) ConfigResetStat

func (c *Ring) ConfigResetStat() *StatusCmd

func (*Ring) ConfigSet

func (c *Ring) ConfigSet(parameter, value string) *StatusCmd

func (*Ring) DbSize

func (c *Ring) DbSize() *IntCmd

func (*Ring) DebugObject

func (c *Ring) DebugObject(key string) *StringCmd

func (*Ring) Decr

func (c *Ring) Decr(key string) *IntCmd

func (*Ring) DecrBy

func (c *Ring) DecrBy(key string, decrement int64) *IntCmd

func (*Ring) Del

func (c *Ring) Del(keys ...string) *IntCmd

func (*Ring) Dump

func (c *Ring) Dump(key string) *StringCmd

func (*Ring) Echo

func (c *Ring) Echo(message interface{}) *StringCmd

func (*Ring) Eval

func (c *Ring) Eval(script string, keys []string, args ...interface{}) *Cmd

func (*Ring) EvalSha

func (c *Ring) EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd

func (*Ring) Exists

func (c *Ring) Exists(keys ...string) *IntCmd

func (*Ring) Expire

func (c *Ring) Expire(key string, expiration time.Duration) *BoolCmd

func (*Ring) ExpireAt

func (c *Ring) ExpireAt(key string, tm time.Time) *BoolCmd

func (*Ring) FlushAll

func (c *Ring) FlushAll() *StatusCmd

func (*Ring) FlushAllAsync

func (c *Ring) FlushAllAsync() *StatusCmd

func (*Ring) FlushDB

func (c *Ring) FlushDB() *StatusCmd

func (*Ring) FlushDBAsync

func (c *Ring) FlushDBAsync() *StatusCmd

func (*Ring) FlushDb

func (c *Ring) FlushDb() *StatusCmd

Deprecated. Use FlushDB instead.

func (*Ring) ForEachShard

func (c *Ring) ForEachShard(fn func(client *Client) error) error

ForEachShard concurrently calls the fn on each live shard in the ring. It returns the first error if any.

func (*Ring) GeoAdd

func (c *Ring) GeoAdd(key string, geoLocation ...*GeoLocation) *IntCmd

func (*Ring) GeoDist

func (c *Ring) GeoDist(key string, member1, member2, unit string) *FloatCmd

func (*Ring) GeoHash

func (c *Ring) GeoHash(key string, members ...string) *StringSliceCmd

func (*Ring) GeoPos

func (c *Ring) GeoPos(key string, members ...string) *GeoPosCmd

func (*Ring) GeoRadius

func (c *Ring) GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd

func (*Ring) GeoRadiusByMember

func (c *Ring) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) *GeoLocationCmd

func (*Ring) Get

func (c *Ring) Get(key string) *StringCmd

func (*Ring) GetBit

func (c *Ring) GetBit(key string, offset int64) *IntCmd

func (*Ring) GetRange

func (c *Ring) GetRange(key string, start, end int64) *StringCmd

func (*Ring) GetSet

func (c *Ring) GetSet(key string, value interface{}) *StringCmd

func (*Ring) HDel

func (c *Ring) HDel(key string, fields ...string) *IntCmd

func (*Ring) HExists

func (c *Ring) HExists(key, field string) *BoolCmd

func (*Ring) HGet

func (c *Ring) HGet(key, field string) *StringCmd

func (*Ring) HGetAll

func (c *Ring) HGetAll(key string) *StringStringMapCmd

func (*Ring) HIncrBy

func (c *Ring) HIncrBy(key, field string, incr int64) *IntCmd

func (*Ring) HIncrByFloat

func (c *Ring) HIncrByFloat(key, field string, incr float64) *FloatCmd

func (*Ring) HKeys

func (c *Ring) HKeys(key string) *StringSliceCmd

func (*Ring) HLen

func (c *Ring) HLen(key string) *IntCmd

func (*Ring) HMGet

func (c *Ring) HMGet(key string, fields ...string) *SliceCmd

func (*Ring) HMSet

func (c *Ring) HMSet(key string, fields map[string]interface{}) *StatusCmd

func (*Ring) HScan

func (c *Ring) HScan(key string, cursor uint64, match string, count int64) *ScanCmd

func (*Ring) HSet

func (c *Ring) HSet(key, field string, value interface{}) *BoolCmd

func (*Ring) HSetNX

func (c *Ring) HSetNX(key, field string, value interface{}) *BoolCmd

func (*Ring) HVals

func (c *Ring) HVals(key string) *StringSliceCmd

func (*Ring) Incr

func (c *Ring) Incr(key string) *IntCmd

func (*Ring) IncrBy

func (c *Ring) IncrBy(key string, value int64) *IntCmd

func (*Ring) IncrByFloat

func (c *Ring) IncrByFloat(key string, value float64) *FloatCmd

func (*Ring) Info

func (c *Ring) Info(section ...string) *StringCmd

func (*Ring) Keys

func (c *Ring) Keys(pattern string) *StringSliceCmd

func (*Ring) LIndex

func (c *Ring) LIndex(key string, index int64) *StringCmd

func (*Ring) LInsert

func (c *Ring) LInsert(key, op string, pivot, value interface{}) *IntCmd

func (*Ring) LInsertAfter

func (c *Ring) LInsertAfter(key string, pivot, value interface{}) *IntCmd

func (*Ring) LInsertBefore

func (c *Ring) LInsertBefore(key string, pivot, value interface{}) *IntCmd

func (*Ring) LLen

func (c *Ring) LLen(key string) *IntCmd

func (*Ring) LPop

func (c *Ring) LPop(key string) *StringCmd

func (*Ring) LPush

func (c *Ring) LPush(key string, values ...interface{}) *IntCmd

func (*Ring) LPushX

func (c *Ring) LPushX(key string, value interface{}) *IntCmd

func (*Ring) LRange

func (c *Ring) LRange(key string, start, stop int64) *StringSliceCmd

func (*Ring) LRem

func (c *Ring) LRem(key string, count int64, value interface{}) *IntCmd

func (*Ring) LSet

func (c *Ring) LSet(key string, index int64, value interface{}) *StatusCmd

func (*Ring) LTrim

func (c *Ring) LTrim(key string, start, stop int64) *StatusCmd

func (*Ring) LastSave

func (c *Ring) LastSave() *IntCmd

func (*Ring) MGet

func (c *Ring) MGet(keys ...string) *SliceCmd

func (*Ring) MSet

func (c *Ring) MSet(pairs ...interface{}) *StatusCmd

func (*Ring) MSetNX

func (c *Ring) MSetNX(pairs ...interface{}) *BoolCmd

func (*Ring) Migrate

func (c *Ring) Migrate(host, port, key string, db int64, timeout time.Duration) *StatusCmd

func (*Ring) Move

func (c *Ring) Move(key string, db int64) *BoolCmd

func (*Ring) ObjectEncoding

func (c *Ring) ObjectEncoding(key string) *StringCmd

func (*Ring) ObjectIdleTime

func (c *Ring) ObjectIdleTime(key string) *DurationCmd

func (*Ring) ObjectRefCount

func (c *Ring) ObjectRefCount(key string) *IntCmd

func (*Ring) Options

func (c *Ring) Options() *RingOptions

Options returns read-only Options that were used to create the client.

func (*Ring) PExpire

func (c *Ring) PExpire(key string, expiration time.Duration) *BoolCmd

func (*Ring) PExpireAt

func (c *Ring) PExpireAt(key string, tm time.Time) *BoolCmd

func (*Ring) PFAdd

func (c *Ring) PFAdd(key string, els ...interface{}) *IntCmd

func (*Ring) PFCount

func (c *Ring) PFCount(keys ...string) *IntCmd

func (*Ring) PFMerge

func (c *Ring) PFMerge(dest string, keys ...string) *StatusCmd

func (*Ring) PSubscribe

func (c *Ring) PSubscribe(channels ...string) *PubSub

PSubscribe subscribes the client to the given patterns.

func (*Ring) PTTL

func (c *Ring) PTTL(key string) *DurationCmd

func (*Ring) Persist

func (c *Ring) Persist(key string) *BoolCmd

func (*Ring) Ping

func (c *Ring) Ping() *StatusCmd

func (*Ring) Pipeline

func (c *Ring) Pipeline() Pipeliner

func (*Ring) Pipelined

func (c *Ring) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)

func (*Ring) PoolStats

func (c *Ring) PoolStats() *PoolStats

PoolStats returns accumulated connection pool stats.

func (*Ring) Process

func (c *Ring) Process(cmd Cmder) error

func (*Ring) PubSubChannels

func (c *Ring) PubSubChannels(pattern string) *StringSliceCmd

func (*Ring) PubSubNumPat

func (c *Ring) PubSubNumPat() *IntCmd

func (*Ring) PubSubNumSub

func (c *Ring) PubSubNumSub(channels ...string) *StringIntMapCmd

func (*Ring) Publish

func (c *Ring) Publish(channel, message string) *IntCmd

Publish posts the message to the channel.

func (*Ring) Quit

func (c *Ring) Quit() *StatusCmd

func (*Ring) RPop

func (c *Ring) RPop(key string) *StringCmd

func (*Ring) RPopLPush

func (c *Ring) RPopLPush(source, destination string) *StringCmd

func (*Ring) RPush

func (c *Ring) RPush(key string, values ...interface{}) *IntCmd

func (*Ring) RPushX

func (c *Ring) RPushX(key string, value interface{}) *IntCmd

func (*Ring) RandomKey

func (c *Ring) RandomKey() *StringCmd

func (*Ring) Rename

func (c *Ring) Rename(key, newkey string) *StatusCmd

func (*Ring) RenameNX

func (c *Ring) RenameNX(key, newkey string) *BoolCmd

func (*Ring) Restore

func (c *Ring) Restore(key string, ttl time.Duration, value string) *StatusCmd

func (*Ring) RestoreReplace

func (c *Ring) RestoreReplace(key string, ttl time.Duration, value string) *StatusCmd

func (*Ring) SAdd

func (c *Ring) SAdd(key string, members ...interface{}) *IntCmd

func (*Ring) SCard

func (c *Ring) SCard(key string) *IntCmd

func (*Ring) SDiff

func (c *Ring) SDiff(keys ...string) *StringSliceCmd

func (*Ring) SDiffStore

func (c *Ring) SDiffStore(destination string, keys ...string) *IntCmd

func (*Ring) SInter

func (c *Ring) SInter(keys ...string) *StringSliceCmd

func (*Ring) SInterStore

func (c *Ring) SInterStore(destination string, keys ...string) *IntCmd

func (*Ring) SIsMember

func (c *Ring) SIsMember(key string, member interface{}) *BoolCmd

func (*Ring) SMembers

func (c *Ring) SMembers(key string) *StringSliceCmd

func (*Ring) SMove

func (c *Ring) SMove(source, destination string, member interface{}) *BoolCmd

func (*Ring) SPop

func (c *Ring) SPop(key string) *StringCmd

Redis `SPOP key` command.

func (*Ring) SPopN

func (c *Ring) SPopN(key string, count int64) *StringSliceCmd

Redis `SPOP key count` command.

func (*Ring) SRandMember

func (c *Ring) SRandMember(key string) *StringCmd

Redis `SRANDMEMBER key` command.

func (*Ring) SRandMemberN

func (c *Ring) SRandMemberN(key string, count int64) *StringSliceCmd

Redis `SRANDMEMBER key count` command.

func (*Ring) SRem

func (c *Ring) SRem(key string, members ...interface{}) *IntCmd

func (*Ring) SScan

func (c *Ring) SScan(key string, cursor uint64, match string, count int64) *ScanCmd

func (*Ring) SUnion

func (c *Ring) SUnion(keys ...string) *StringSliceCmd

func (*Ring) SUnionStore

func (c *Ring) SUnionStore(destination string, keys ...string) *IntCmd

func (*Ring) Save

func (c *Ring) Save() *StatusCmd

func (*Ring) Scan

func (c *Ring) Scan(cursor uint64, match string, count int64) *ScanCmd

func (*Ring) ScriptExists

func (c *Ring) ScriptExists(scripts ...string) *BoolSliceCmd

func (*Ring) ScriptFlush

func (c *Ring) ScriptFlush() *StatusCmd

func (*Ring) ScriptKill

func (c *Ring) ScriptKill() *StatusCmd

func (*Ring) ScriptLoad

func (c *Ring) ScriptLoad(script string) *StringCmd

func (*Ring) Set

func (c *Ring) Set(key string, value interface{}, expiration time.Duration) *StatusCmd

Redis `SET key value [expiration]` command.

Use expiration for `SETEX`-like behavior. Zero expiration means the key has no expiration time.

func (*Ring) SetBit

func (c *Ring) SetBit(key string, offset int64, value int) *IntCmd

func (*Ring) SetNX

func (c *Ring) SetNX(key string, value interface{}, expiration time.Duration) *BoolCmd

Redis `SET key value [expiration] NX` command.

Zero expiration means the key has no expiration time.

func (*Ring) SetRange

func (c *Ring) SetRange(key string, offset int64, value string) *IntCmd

func (*Ring) SetXX

func (c *Ring) SetXX(key string, value interface{}, expiration time.Duration) *BoolCmd

Redis `SET key value [expiration] XX` command.

Zero expiration means the key has no expiration time.

func (*Ring) Shutdown

func (c *Ring) Shutdown() *StatusCmd

func (*Ring) ShutdownNoSave

func (c *Ring) ShutdownNoSave() *StatusCmd

func (*Ring) ShutdownSave

func (c *Ring) ShutdownSave() *StatusCmd

func (*Ring) SlaveOf

func (c *Ring) SlaveOf(host, port string) *StatusCmd

func (*Ring) SlowLog

func (c *Ring) SlowLog()

func (*Ring) Sort

func (c *Ring) Sort(key string, sort Sort) *StringSliceCmd

func (*Ring) SortInterfaces

func (c *Ring) SortInterfaces(key string, sort Sort) *SliceCmd

func (*Ring) StrLen

func (c *Ring) StrLen(key string) *IntCmd

func (*Ring) Subscribe

func (c *Ring) Subscribe(channels ...string) *PubSub

Subscribe subscribes the client to the specified channels.

func (*Ring) Sync

func (c *Ring) Sync()

func (*Ring) TTL

func (c *Ring) TTL(key string) *DurationCmd

func (*Ring) Time

func (c *Ring) Time() *TimeCmd

func (*Ring) Type

func (c *Ring) Type(key string) *StatusCmd
func (c *Ring) Unlink(keys ...string) *IntCmd

func (*Ring) Wait

func (c *Ring) Wait(numSlaves int, timeout time.Duration) *IntCmd

func (*Ring) ZAdd

func (c *Ring) ZAdd(key string, members ...Z) *IntCmd

Redis `ZADD key score member [score member ...]` command.

func (*Ring) ZAddCh

func (c *Ring) ZAddCh(key string, members ...Z) *IntCmd

Redis `ZADD key CH score member [score member ...]` command.

func (*Ring) ZAddNX

func (c *Ring) ZAddNX(key string, members ...Z) *IntCmd

Redis `ZADD key NX score member [score member ...]` command.

func (*Ring) ZAddNXCh

func (c *Ring) ZAddNXCh(key string, members ...Z) *IntCmd

Redis `ZADD key NX CH score member [score member ...]` command.

func (*Ring) ZAddXX

func (c *Ring) ZAddXX(key string, members ...Z) *IntCmd

Redis `ZADD key XX score member [score member ...]` command.

func (*Ring) ZAddXXCh

func (c *Ring) ZAddXXCh(key string, members ...Z) *IntCmd

Redis `ZADD key XX CH score member [score member ...]` command.

func (*Ring) ZCard

func (c *Ring) ZCard(key string) *IntCmd

func (*Ring) ZCount

func (c *Ring) ZCount(key, min, max string) *IntCmd

func (*Ring) ZIncr

func (c *Ring) ZIncr(key string, member Z) *FloatCmd

Redis `ZADD key INCR score member` command.

func (*Ring) ZIncrBy

func (c *Ring) ZIncrBy(key string, increment float64, member string) *FloatCmd

func (*Ring) ZIncrNX

func (c *Ring) ZIncrNX(key string, member Z) *FloatCmd

Redis `ZADD key NX INCR score member` command.

func (*Ring) ZIncrXX

func (c *Ring) ZIncrXX(key string, member Z) *FloatCmd

Redis `ZADD key XX INCR score member` command.

func (*Ring) ZInterStore

func (c *Ring) ZInterStore(destination string, store ZStore, keys ...string) *IntCmd

func (*Ring) ZRange

func (c *Ring) ZRange(key string, start, stop int64) *StringSliceCmd

func (*Ring) ZRangeByLex

func (c *Ring) ZRangeByLex(key string, opt ZRangeBy) *StringSliceCmd

func (*Ring) ZRangeByScore

func (c *Ring) ZRangeByScore(key string, opt ZRangeBy) *StringSliceCmd

func (*Ring) ZRangeByScoreWithScores

func (c *Ring) ZRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd

func (*Ring) ZRangeWithScores

func (c *Ring) ZRangeWithScores(key string, start, stop int64) *ZSliceCmd

func (*Ring) ZRank

func (c *Ring) ZRank(key, member string) *IntCmd

func (*Ring) ZRem

func (c *Ring) ZRem(key string, members ...interface{}) *IntCmd

func (*Ring) ZRemRangeByLex

func (c *Ring) ZRemRangeByLex(key, min, max string) *IntCmd

func (*Ring) ZRemRangeByRank

func (c *Ring) ZRemRangeByRank(key string, start, stop int64) *IntCmd

func (*Ring) ZRemRangeByScore

func (c *Ring) ZRemRangeByScore(key, min, max string) *IntCmd

func (*Ring) ZRevRange

func (c *Ring) ZRevRange(key string, start, stop int64) *StringSliceCmd

func (*Ring) ZRevRangeByLex

func (c *Ring) ZRevRangeByLex(key string, opt ZRangeBy) *StringSliceCmd

func (*Ring) ZRevRangeByScore

func (c *Ring) ZRevRangeByScore(key string, opt ZRangeBy) *StringSliceCmd

func (*Ring) ZRevRangeByScoreWithScores

func (c *Ring) ZRevRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd

func (*Ring) ZRevRangeWithScores

func (c *Ring) ZRevRangeWithScores(key string, start, stop int64) *ZSliceCmd

func (*Ring) ZRevRank

func (c *Ring) ZRevRank(key, member string) *IntCmd

func (*Ring) ZScan

func (c *Ring) ZScan(key string, cursor uint64, match string, count int64) *ScanCmd

func (*Ring) ZScore

func (c *Ring) ZScore(key, member string) *FloatCmd

func (*Ring) ZUnionStore

func (c *Ring) ZUnionStore(dest string, store ZStore, keys ...string) *IntCmd

type RingOptions

RingOptions are used to configure a ring client and should be passed to NewRing.

type RingOptions struct {
    // Map of name => host:port addresses of ring shards.
    Addrs map[string]string

    // Frequency of PING commands sent to check shards availability.
    // Shard is considered down after 3 subsequent failed checks.
    HeartbeatFrequency time.Duration

    OnConnect func(*Conn) error

    DB       int
    Password string

    MaxRetries int

    DialTimeout  time.Duration
    ReadTimeout  time.Duration
    WriteTimeout time.Duration

    PoolSize           int
    PoolTimeout        time.Duration
    IdleTimeout        time.Duration
    IdleCheckFrequency time.Duration
}

type ScanCmd

type ScanCmd struct {
    // contains filtered or unexported fields
}

func NewScanCmd

func NewScanCmd(process func(cmd Cmder) error, args ...interface{}) *ScanCmd

func NewScanCmdResult

func NewScanCmdResult(keys []string, cursor uint64, err error) *ScanCmd

NewScanCmdResult returns a ScanCmd initalised with val and err for testing

func (*ScanCmd) Err

func (cmd *ScanCmd) Err() error

func (*ScanCmd) Iterator

func (cmd *ScanCmd) Iterator() *ScanIterator

Iterator creates a new ScanIterator.

Example

Code:

iter := client.Scan(0, "", 0).Iterator()
for iter.Next() {
    fmt.Println(iter.Val())
}
if err := iter.Err(); err != nil {
    panic(err)
}

func (*ScanCmd) Name

func (cmd *ScanCmd) Name() string

func (*ScanCmd) Result

func (cmd *ScanCmd) Result() (keys []string, cursor uint64, err error)

func (*ScanCmd) String

func (cmd *ScanCmd) String() string

func (*ScanCmd) Val

func (cmd *ScanCmd) Val() (keys []string, cursor uint64)

type ScanIterator

ScanIterator is used to incrementally iterate over a collection of elements. It's safe for concurrent use by multiple goroutines.

type ScanIterator struct {
    // contains filtered or unexported fields
}

Example

Code:

iter := client.Scan(0, "", 0).Iterator()
for iter.Next() {
    fmt.Println(iter.Val())
}
if err := iter.Err(); err != nil {
    panic(err)
}

func (*ScanIterator) Err

func (it *ScanIterator) Err() error

Err returns the last iterator error, if any.

func (*ScanIterator) Next

func (it *ScanIterator) Next() bool

Next advances the cursor and returns true if more values can be read.

func (*ScanIterator) Val

func (it *ScanIterator) Val() string

Val returns the key/field at the current cursor position.

type Script

type Script struct {
    // contains filtered or unexported fields
}

Example

Code:

IncrByXX := redis.NewScript(`
    if redis.call("GET", KEYS[1]) ~= false then
        return redis.call("INCRBY", KEYS[1], ARGV[1])
    end
    return false
`)

n, err := IncrByXX.Run(client, []string{"xx_counter"}, 2).Result()
fmt.Println(n, err)

err = client.Set("xx_counter", "40", 0).Err()
if err != nil {
    panic(err)
}

n, err = IncrByXX.Run(client, []string{"xx_counter"}, 2).Result()
fmt.Println(n, err)

Output:

<nil> redis: nil
42 <nil>

func NewScript

func NewScript(src string) *Script

func (*Script) Eval

func (s *Script) Eval(c scripter, keys []string, args ...interface{}) *Cmd

func (*Script) EvalSha

func (s *Script) EvalSha(c scripter, keys []string, args ...interface{}) *Cmd

func (*Script) Exists

func (s *Script) Exists(c scripter) *BoolSliceCmd

func (*Script) Hash

func (s *Script) Hash() string

func (*Script) Load

func (s *Script) Load(c scripter) *StringCmd

func (*Script) Run

func (s *Script) Run(c scripter, keys []string, args ...interface{}) *Cmd

Run optimistically uses EVALSHA to run the script. If script does not exist it is retried using EVAL.

type SliceCmd

type SliceCmd struct {
    // contains filtered or unexported fields
}

func NewSliceCmd

func NewSliceCmd(args ...interface{}) *SliceCmd

func NewSliceResult

func NewSliceResult(val []interface{}, err error) *SliceCmd

NewSliceResult returns a SliceCmd initalised with val and err for testing

func (*SliceCmd) Err

func (cmd *SliceCmd) Err() error

func (*SliceCmd) Name

func (cmd *SliceCmd) Name() string

func (*SliceCmd) Result

func (cmd *SliceCmd) Result() ([]interface{}, error)

func (*SliceCmd) String

func (cmd *SliceCmd) String() string

func (*SliceCmd) Val

func (cmd *SliceCmd) Val() []interface{}

type Sort

type Sort struct {
    By            string
    Offset, Count float64
    Get           []string
    Order         string
    IsAlpha       bool
    Store         string
}

type StatefulCmdable

type StatefulCmdable interface {
    Cmdable
    Auth(password string) *StatusCmd
    Select(index int) *StatusCmd
    ClientSetName(name string) *BoolCmd
    ReadOnly() *StatusCmd
    ReadWrite() *StatusCmd
}

type StatusCmd

type StatusCmd struct {
    // contains filtered or unexported fields
}

func NewStatusCmd

func NewStatusCmd(args ...interface{}) *StatusCmd

func NewStatusResult

func NewStatusResult(val string, err error) *StatusCmd

NewStatusResult returns a StatusCmd initalised with val and err for testing

func (*StatusCmd) Err

func (cmd *StatusCmd) Err() error

func (*StatusCmd) Name

func (cmd *StatusCmd) Name() string

func (*StatusCmd) Result

func (cmd *StatusCmd) Result() (string, error)

func (*StatusCmd) String

func (cmd *StatusCmd) String() string

func (*StatusCmd) Val

func (cmd *StatusCmd) Val() string

type StringCmd

type StringCmd struct {
    // contains filtered or unexported fields
}

func NewStringCmd

func NewStringCmd(args ...interface{}) *StringCmd

func NewStringResult

func NewStringResult(val string, err error) *StringCmd

NewStringResult returns a StringCmd initalised with val and err for testing

func (*StringCmd) Bytes

func (cmd *StringCmd) Bytes() ([]byte, error)

func (*StringCmd) Err

func (cmd *StringCmd) Err() error

func (*StringCmd) Float64

func (cmd *StringCmd) Float64() (float64, error)

func (*StringCmd) Int64

func (cmd *StringCmd) Int64() (int64, error)

func (*StringCmd) Name

func (cmd *StringCmd) Name() string

func (*StringCmd) Result

func (cmd *StringCmd) Result() (string, error)

func (*StringCmd) Scan

func (cmd *StringCmd) Scan(val interface{}) error

func (*StringCmd) String

func (cmd *StringCmd) String() string

func (*StringCmd) Uint64

func (cmd *StringCmd) Uint64() (uint64, error)

func (*StringCmd) Val

func (cmd *StringCmd) Val() string

type StringIntMapCmd

type StringIntMapCmd struct {
    // contains filtered or unexported fields
}

func NewStringIntMapCmd

func NewStringIntMapCmd(args ...interface{}) *StringIntMapCmd

func NewStringIntMapCmdResult

func NewStringIntMapCmdResult(val map[string]int64, err error) *StringIntMapCmd

NewStringIntMapCmdResult returns a StringIntMapCmd initalised with val and err for testing

func (*StringIntMapCmd) Err

func (cmd *StringIntMapCmd) Err() error

func (*StringIntMapCmd) Name

func (cmd *StringIntMapCmd) Name() string

func (*StringIntMapCmd) Result

func (cmd *StringIntMapCmd) Result() (map[string]int64, error)

func (*StringIntMapCmd) String

func (cmd *StringIntMapCmd) String() string

func (*StringIntMapCmd) Val

func (cmd *StringIntMapCmd) Val() map[string]int64

type StringSliceCmd

type StringSliceCmd struct {
    // contains filtered or unexported fields
}

func NewStringSliceCmd

func NewStringSliceCmd(args ...interface{}) *StringSliceCmd

func NewStringSliceResult

func NewStringSliceResult(val []string, err error) *StringSliceCmd

NewStringSliceResult returns a StringSliceCmd initalised with val and err for testing

func (*StringSliceCmd) Err

func (cmd *StringSliceCmd) Err() error

func (*StringSliceCmd) Name

func (cmd *StringSliceCmd) Name() string

func (*StringSliceCmd) Result

func (cmd *StringSliceCmd) Result() ([]string, error)

func (*StringSliceCmd) ScanSlice

func (cmd *StringSliceCmd) ScanSlice(container interface{}) error

func (*StringSliceCmd) String

func (cmd *StringSliceCmd) String() string

func (*StringSliceCmd) Val

func (cmd *StringSliceCmd) Val() []string

type StringStringMapCmd

type StringStringMapCmd struct {
    // contains filtered or unexported fields
}

func NewStringStringMapCmd

func NewStringStringMapCmd(args ...interface{}) *StringStringMapCmd

func NewStringStringMapResult

func NewStringStringMapResult(val map[string]string, err error) *StringStringMapCmd

NewStringStringMapResult returns a StringStringMapCmd initalised with val and err for testing

func (*StringStringMapCmd) Err

func (cmd *StringStringMapCmd) Err() error

func (*StringStringMapCmd) Name

func (cmd *StringStringMapCmd) Name() string

func (*StringStringMapCmd) Result

func (cmd *StringStringMapCmd) Result() (map[string]string, error)

func (*StringStringMapCmd) String

func (cmd *StringStringMapCmd) String() string

func (*StringStringMapCmd) Val

func (cmd *StringStringMapCmd) Val() map[string]string

type Subscription

Message received after a successful subscription to channel.

type Subscription struct {
    // Can be "subscribe", "unsubscribe", "psubscribe" or "punsubscribe".
    Kind string
    // Channel name we have subscribed to.
    Channel string
    // Number of channels we are currently subscribed to.
    Count int
}

func (*Subscription) String

func (m *Subscription) String() string

type TimeCmd

type TimeCmd struct {
    // contains filtered or unexported fields
}

func NewTimeCmd

func NewTimeCmd(args ...interface{}) *TimeCmd

func (*TimeCmd) Err

func (cmd *TimeCmd) Err() error

func (*TimeCmd) Name

func (cmd *TimeCmd) Name() string

func (*TimeCmd) Result

func (cmd *TimeCmd) Result() (time.Time, error)

func (*TimeCmd) String

func (cmd *TimeCmd) String() string

func (*TimeCmd) Val

func (cmd *TimeCmd) Val() time.Time

type Tx

Tx implements Redis transactions as described in http://redis.io/topics/transactions. It's NOT safe for concurrent use by multiple goroutines, because Exec resets list of watched keys. If you don't need WATCH it is better to use Pipeline.

type Tx struct {
    // contains filtered or unexported fields
}

func (*Tx) Auth

func (c *Tx) Auth(password string) *StatusCmd

func (*Tx) ClientSetName

func (c *Tx) ClientSetName(name string) *BoolCmd

ClientSetName assigns a name to the connection.

func (*Tx) Close

func (c *Tx) Close() error

close closes the transaction, releasing any open resources.

func (*Tx) Pipeline

func (c *Tx) Pipeline() Pipeliner

func (*Tx) Pipelined

func (c *Tx) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)

Pipelined executes commands queued in the fn in a transaction and restores the connection state to normal.

When using WATCH, EXEC will execute commands only if the watched keys were not modified, allowing for a check-and-set mechanism.

Exec always returns list of commands. If transaction fails TxFailedErr is returned. Otherwise Exec returns error of the first failed command or nil.

func (*Tx) Process

func (c *Tx) Process(cmd Cmder) error

func (*Tx) ReadOnly

func (c *Tx) ReadOnly() *StatusCmd

func (*Tx) ReadWrite

func (c *Tx) ReadWrite() *StatusCmd

func (*Tx) Select

func (c *Tx) Select(index int) *StatusCmd

func (*Tx) String

func (c *Tx) String() string

func (*Tx) Unwatch

func (c *Tx) Unwatch(keys ...string) *StatusCmd

Unwatch flushes all the previously watched keys for a transaction.

func (*Tx) Watch

func (c *Tx) Watch(keys ...string) *StatusCmd

Watch marks the keys to be watched for conditional execution of a transaction.

func (*Tx) WrapProcess

func (c *Tx) WrapProcess(fn func(oldProcess func(cmd Cmder) error) func(cmd Cmder) error)

WrapProcess replaces the process func. It takes a function createWrapper which is supplied by the user. createWrapper takes the old process func as an input and returns the new wrapper process func. createWrapper should use call the old process func within the new process func.

type UniversalClient

UniversalClient is an abstract client which - based on the provided options - can connect to either clusters, or sentinel-backed failover instances or simple single-instance servers. This can be useful for testing cluster-specific applications locally.

type UniversalClient interface {
    Cmdable
    Process(cmd Cmder) error
    Close() error
}

func NewUniversalClient

func NewUniversalClient(opts *UniversalOptions) UniversalClient

NewUniversalClient returns a new multi client. The type of client returned depends on the following three conditions:

1. if a MasterName is passed a sentinel-backed FailoverClient will be returned 2. if the number of Addrs is two or more, a ClusterClient will be returned 3. otherwise, a single-node redis Client will be returned.

Example (Cluster)

Code:

client := redis.NewUniversalClient(&redis.UniversalOptions{
    Addrs: []string{":7000", ":7001", ":7002", ":7003", ":7004", ":7005"},
})
defer client.Close()

client.Ping()

Example (Failover)

Code:

client := redis.NewUniversalClient(&redis.UniversalOptions{
    MasterName: "master",
    Addrs:      []string{":26379"},
})
defer client.Close()

client.Ping()

Example (Simple)

Code:

client := redis.NewUniversalClient(&redis.UniversalOptions{
    Addrs: []string{":6379"},
})
defer client.Close()

client.Ping()

type UniversalOptions

UniversalOptions information is required by UniversalClient to establish connections.

type UniversalOptions struct {
    // Either a single address or a seed list of host:port addresses
    // of cluster/sentinel nodes.
    Addrs []string

    // The sentinel master name.
    // Only failover clients.
    MasterName string

    // Database to be selected after connecting to the server.
    // Only single-node and failover clients.
    DB int

    // Enables read only queries on slave nodes.
    // Only cluster and single-node clients.
    ReadOnly bool

    MaxRedirects   int
    RouteByLatency bool

    MaxRetries         int
    Password           string
    DialTimeout        time.Duration
    ReadTimeout        time.Duration
    WriteTimeout       time.Duration
    PoolSize           int
    PoolTimeout        time.Duration
    IdleTimeout        time.Duration
    IdleCheckFrequency time.Duration
}

type Z

Z represents sorted set member.

type Z struct {
    Score  float64
    Member interface{}
}

type ZRangeBy

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

type ZSliceCmd

type ZSliceCmd struct {
    // contains filtered or unexported fields
}

func NewZSliceCmd

func NewZSliceCmd(args ...interface{}) *ZSliceCmd

func NewZSliceCmdResult

func NewZSliceCmdResult(val []Z, err error) *ZSliceCmd

NewZSliceCmdResult returns a ZSliceCmd initalised with val and err for testing

func (*ZSliceCmd) Err

func (cmd *ZSliceCmd) Err() error

func (*ZSliceCmd) Name

func (cmd *ZSliceCmd) Name() string

func (*ZSliceCmd) Result

func (cmd *ZSliceCmd) Result() ([]Z, error)

func (*ZSliceCmd) String

func (cmd *ZSliceCmd) String() string

func (*ZSliceCmd) Val

func (cmd *ZSliceCmd) Val() []Z

type ZStore

ZStore is used as an arg to ZInterStore and ZUnionStore.

type ZStore struct {
    Weights []float64
    // Can be SUM, MIN or MAX.
    Aggregate string
}

Subdirectories

Name Synopsis
..