Back to godoc.org
github.com/go-redis/redis/v8

Package redis

v8.3.2
Latest Go to latest

The highest tagged major version is v8.

Published: Oct 17, 2020 | License: BSD-2-Clause | Module: github.com/go-redis/redis/v8

Overview

Package redis implements a Redis client.

Example (CustomCommand)

Code:

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

v, err := Get(ctx, rdb, "key_does_not_exist").Result()
fmt.Printf("%q %s", v, err)
"" redis: nil
Example (CustomCommand2)

Code:

v, err := rdb.Do(ctx, "get", "key_does_not_exist").Text()
fmt.Printf("%q %s", v, err)
"" redis: nil
Example (Instrumentation)

Code:

rdb := redis.NewClient(&redis.Options{
	Addr: ":6379",
})
rdb.AddHook(redisHook{})

rdb.Ping(ctx)
starting processing: <ping: >
finished processing: <ping: PONG>

Index

Examples

Constants

const KeepTTL = -1

KeepTTL is an option for Set command to keep key's existing TTL. For example:

rdb.Set(ctx, key, value, redis.KeepTTL)
const Nil = proto.Nil

Nil reply returned by Redis when key does not exist.

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

TxFailedErr transaction redis failed.

Variables

var ErrClosed = pool.ErrClosed

func SetLogger

func SetLogger(logger internal.Logging)

type BitCount

type BitCount struct {
	Start, End int64
}

type BoolCmd

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

func NewBoolCmd

func NewBoolCmd(ctx context.Context, args ...interface{}) *BoolCmd

func NewBoolResult

func NewBoolResult(val bool, err error) *BoolCmd

NewBoolResult returns a BoolCmd initialised with val and err for testing.

func (*BoolCmd) Args

func (cmd *BoolCmd) Args() []interface{}

func (*BoolCmd) Err

func (cmd *BoolCmd) Err() error

func (*BoolCmd) FullName

func (cmd *BoolCmd) FullName() string

func (*BoolCmd) Name

func (cmd *BoolCmd) Name() string

func (*BoolCmd) Result

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

func (*BoolCmd) SetErr

func (cmd *BoolCmd) SetErr(e 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(ctx context.Context, args ...interface{}) *BoolSliceCmd

func NewBoolSliceResult

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

NewBoolSliceResult returns a BoolSliceCmd initialised with val and err for testing.

func (*BoolSliceCmd) Args

func (cmd *BoolSliceCmd) Args() []interface{}

func (*BoolSliceCmd) Err

func (cmd *BoolSliceCmd) Err() error

func (*BoolSliceCmd) FullName

func (cmd *BoolSliceCmd) FullName() string

func (*BoolSliceCmd) Name

func (cmd *BoolSliceCmd) Name() string

func (*BoolSliceCmd) Result

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

func (*BoolSliceCmd) SetErr

func (cmd *BoolSliceCmd) SetErr(e error)

func (*BoolSliceCmd) String

func (cmd *BoolSliceCmd) String() string

func (*BoolSliceCmd) Val

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

type Client

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

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

Example

Code:

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

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

val2, err := rdb.Get(ctx, "missing_key").Result()
if err == redis.Nil {
	fmt.Println("missing_key does not exist")
} else if err != nil {
	panic(err)
} else {
	fmt.Println("missing_key", val2)
}
key value
missing_key does not exist

func NewClient

func NewClient(opt *Options) *Client

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

Example

Code:

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

pong, err := rdb.Ping(ctx).Result()
fmt.Println(pong, err)
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.
rdb := redis.NewFailoverClient(&redis.FailoverOptions{
	MasterName:    "master",
	SentinelAddrs: []string{":26379"},
})
rdb.Ping(ctx)

func (*Client) AddHook

func (hs *Client) AddHook(hook Hook)

func (Client) Append

func (c Client) Append(ctx context.Context, key, value string) *IntCmd

func (Client) BLPop

func (c Client) BLPop(ctx context.Context, timeout time.Duration, keys ...string) *StringSliceCmd
Example

Code:

if err := rdb.RPush(ctx, "queue", "message").Err(); err != nil {
	panic(err)
}

// use `rdb.BLPop(0, "queue")` for infinite waiting time
result, err := rdb.BLPop(ctx, 1*time.Second, "queue").Result()
if err != nil {
	panic(err)
}

fmt.Println(result[0], result[1])
queue message

func (Client) BRPop

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

func (Client) BRPopLPush

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

func (Client) BZPopMax

func (c Client) BZPopMax(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd

Redis `BZPOPMAX key [key ...] timeout` command.

func (Client) BZPopMin

func (c Client) BZPopMin(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd

Redis `BZPOPMIN key [key ...] timeout` command.

func (Client) BgRewriteAOF

func (c Client) BgRewriteAOF(ctx context.Context) *StatusCmd

func (Client) BgSave

func (c Client) BgSave(ctx context.Context) *StatusCmd

func (Client) BitCount

func (c Client) BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd

func (Client) BitField

func (c Client) BitField(ctx context.Context, key string, args ...interface{}) *IntSliceCmd

func (Client) BitOpAnd

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

func (Client) BitOpNot

func (c Client) BitOpNot(ctx context.Context, destKey string, key string) *IntCmd

func (Client) BitOpOr

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

func (Client) BitOpXor

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

func (Client) BitPos

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

func (Client) ClientGetName

func (c Client) ClientGetName(ctx context.Context) *StringCmd

ClientGetName returns the name of the connection.

func (Client) ClientID

func (c Client) ClientID(ctx context.Context) *IntCmd

func (Client) ClientKill

func (c Client) ClientKill(ctx context.Context, ipPort string) *StatusCmd

func (Client) ClientKillByFilter

func (c Client) ClientKillByFilter(ctx context.Context, keys ...string) *IntCmd

ClientKillByFilter is new style syntax, while the ClientKill is old

CLIENT KILL <option> [value] ... <option> [value]

func (Client) ClientList

func (c Client) ClientList(ctx context.Context) *StringCmd

func (Client) ClientPause

func (c Client) ClientPause(ctx context.Context, dur time.Duration) *BoolCmd

func (Client) ClientUnblock

func (c Client) ClientUnblock(ctx context.Context, id int64) *IntCmd

func (Client) ClientUnblockWithError

func (c Client) ClientUnblockWithError(ctx context.Context, id int64) *IntCmd

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(ctx context.Context, slots ...int) *StatusCmd

func (Client) ClusterAddSlotsRange

func (c Client) ClusterAddSlotsRange(ctx context.Context, min, max int) *StatusCmd

func (Client) ClusterCountFailureReports

func (c Client) ClusterCountFailureReports(ctx context.Context, nodeID string) *IntCmd

func (Client) ClusterCountKeysInSlot

func (c Client) ClusterCountKeysInSlot(ctx context.Context, slot int) *IntCmd

func (Client) ClusterDelSlots

func (c Client) ClusterDelSlots(ctx context.Context, slots ...int) *StatusCmd

func (Client) ClusterDelSlotsRange

func (c Client) ClusterDelSlotsRange(ctx context.Context, min, max int) *StatusCmd

func (Client) ClusterFailover

func (c Client) ClusterFailover(ctx context.Context) *StatusCmd

func (Client) ClusterForget

func (c Client) ClusterForget(ctx context.Context, nodeID string) *StatusCmd

func (Client) ClusterGetKeysInSlot

func (c Client) ClusterGetKeysInSlot(ctx context.Context, slot int, count int) *StringSliceCmd

func (Client) ClusterInfo

func (c Client) ClusterInfo(ctx context.Context) *StringCmd

func (Client) ClusterKeySlot

func (c Client) ClusterKeySlot(ctx context.Context, key string) *IntCmd

func (Client) ClusterMeet

func (c Client) ClusterMeet(ctx context.Context, host, port string) *StatusCmd

func (Client) ClusterNodes

func (c Client) ClusterNodes(ctx context.Context) *StringCmd

func (Client) ClusterReplicate

func (c Client) ClusterReplicate(ctx context.Context, nodeID string) *StatusCmd

func (Client) ClusterResetHard

func (c Client) ClusterResetHard(ctx context.Context) *StatusCmd

func (Client) ClusterResetSoft

func (c Client) ClusterResetSoft(ctx context.Context) *StatusCmd

func (Client) ClusterSaveConfig

func (c Client) ClusterSaveConfig(ctx context.Context) *StatusCmd

func (Client) ClusterSlaves

func (c Client) ClusterSlaves(ctx context.Context, nodeID string) *StringSliceCmd

func (Client) ClusterSlots

func (c Client) ClusterSlots(ctx context.Context) *ClusterSlotsCmd

func (Client) Command

func (c Client) Command(ctx context.Context) *CommandsInfoCmd

func (Client) ConfigGet

func (c Client) ConfigGet(ctx context.Context, parameter string) *SliceCmd

func (Client) ConfigResetStat

func (c Client) ConfigResetStat(ctx context.Context) *StatusCmd

func (Client) ConfigRewrite

func (c Client) ConfigRewrite(ctx context.Context) *StatusCmd

func (Client) ConfigSet

func (c Client) ConfigSet(ctx context.Context, parameter, value string) *StatusCmd

func (*Client) Conn

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

func (*Client) Context

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

func (Client) DBSize

func (c Client) DBSize(ctx context.Context) *IntCmd

func (Client) DebugObject

func (c Client) DebugObject(ctx context.Context, key string) *StringCmd

func (Client) Decr

func (c Client) Decr(ctx context.Context, key string) *IntCmd

func (Client) DecrBy

func (c Client) DecrBy(ctx context.Context, key string, decrement int64) *IntCmd

func (Client) Del

func (c Client) Del(ctx context.Context, keys ...string) *IntCmd

func (*Client) Do

func (c *Client) Do(ctx context.Context, args ...interface{}) *Cmd

Do creates a Cmd from the args and processes the cmd.

func (Client) Dump

func (c Client) Dump(ctx context.Context, key string) *StringCmd

func (Client) Echo

func (c Client) Echo(ctx context.Context, message interface{}) *StringCmd

func (Client) Eval

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

func (Client) EvalSha

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

func (Client) Exists

func (c Client) Exists(ctx context.Context, keys ...string) *IntCmd

func (Client) Expire

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

func (Client) ExpireAt

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

func (Client) FlushAll

func (c Client) FlushAll(ctx context.Context) *StatusCmd

func (Client) FlushAllAsync

func (c Client) FlushAllAsync(ctx context.Context) *StatusCmd

func (Client) FlushDB

func (c Client) FlushDB(ctx context.Context) *StatusCmd

func (Client) FlushDBAsync

func (c Client) FlushDBAsync(ctx context.Context) *StatusCmd

func (Client) GeoAdd

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

func (Client) GeoDist

func (c Client) GeoDist(
	ctx context.Context, key string, member1, member2, unit string,
) *FloatCmd

func (Client) GeoHash

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

func (Client) GeoPos

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

func (Client) GeoRadius

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

GeoRadius is a read-only GEORADIUS_RO command.

func (Client) GeoRadiusByMember

func (c Client) GeoRadiusByMember(
	ctx context.Context, key, member string, query *GeoRadiusQuery,
) *GeoLocationCmd

GeoRadius is a read-only GEORADIUSBYMEMBER_RO command.

func (Client) GeoRadiusByMemberStore

func (c Client) GeoRadiusByMemberStore(
	ctx context.Context, key, member string, query *GeoRadiusQuery,
) *IntCmd

GeoRadiusByMemberStore is a writing GEORADIUSBYMEMBER command.

func (Client) GeoRadiusStore

func (c Client) GeoRadiusStore(
	ctx context.Context, key string, longitude, latitude float64, query *GeoRadiusQuery,
) *IntCmd

GeoRadiusStore is a writing GEORADIUS command.

func (Client) Get

func (c Client) Get(ctx context.Context, key string) *StringCmd

Redis `GET key` command. It returns redis.Nil error when key does not exist.

func (Client) GetBit

func (c Client) GetBit(ctx context.Context, key string, offset int64) *IntCmd

func (Client) GetRange

func (c Client) GetRange(ctx context.Context, key string, start, end int64) *StringCmd

func (Client) GetSet

func (c Client) GetSet(ctx context.Context, key string, value interface{}) *StringCmd

func (Client) HDel

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

func (Client) HExists

func (c Client) HExists(ctx context.Context, key, field string) *BoolCmd

func (Client) HGet

func (c Client) HGet(ctx context.Context, key, field string) *StringCmd

func (Client) HGetAll

func (c Client) HGetAll(ctx context.Context, key string) *StringStringMapCmd

func (Client) HIncrBy

func (c Client) HIncrBy(ctx context.Context, key, field string, incr int64) *IntCmd

func (Client) HIncrByFloat

func (c Client) HIncrByFloat(ctx context.Context, key, field string, incr float64) *FloatCmd

func (Client) HKeys

func (c Client) HKeys(ctx context.Context, key string) *StringSliceCmd

func (Client) HLen

func (c Client) HLen(ctx context.Context, key string) *IntCmd

func (Client) HMGet

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

HMGet returns the values for the specified fields in the hash stored at key. It returns an interface{} to distinguish between empty string and nil value.

func (Client) HMSet

func (c Client) HMSet(ctx context.Context, key string, values ...interface{}) *BoolCmd

HMSet is a deprecated version of HSet left for compatibility with Redis 3.

func (Client) HScan

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

func (Client) HSet

func (c Client) HSet(ctx context.Context, key string, values ...interface{}) *IntCmd

HSet accepts values in following formats:

- HSet("myhash", "key1", "value1", "key2", "value2")
- HSet("myhash", []string{"key1", "value1", "key2", "value2"})
- HSet("myhash", map[string]interface{}{"key1": "value1", "key2": "value2"})

Note that it requires Redis v4 for multiple field/value pairs support.

func (Client) HSetNX

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

func (Client) HVals

func (c Client) HVals(ctx context.Context, key string) *StringSliceCmd

func (Client) Incr

func (c Client) Incr(ctx context.Context, key string) *IntCmd
Example

Code:

result, err := rdb.Incr(ctx, "counter").Result()
if err != nil {
	panic(err)
}

fmt.Println(result)
1

func (Client) IncrBy

func (c Client) IncrBy(ctx context.Context, key string, value int64) *IntCmd

func (Client) IncrByFloat

func (c Client) IncrByFloat(ctx context.Context, key string, value float64) *FloatCmd

func (Client) Info

func (c Client) Info(ctx context.Context, section ...string) *StringCmd

func (Client) Keys

func (c Client) Keys(ctx context.Context, pattern string) *StringSliceCmd

func (Client) LIndex

func (c Client) LIndex(ctx context.Context, key string, index int64) *StringCmd

func (Client) LInsert

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

func (Client) LInsertAfter

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

func (Client) LInsertBefore

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

func (Client) LLen

func (c Client) LLen(ctx context.Context, key string) *IntCmd

func (Client) LPop

func (c Client) LPop(ctx context.Context, key string) *StringCmd

func (Client) LPush

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

func (Client) LPushX

func (c Client) LPushX(ctx context.Context, key string, values ...interface{}) *IntCmd

func (Client) LRange

func (c Client) LRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd

func (Client) LRem

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

func (Client) LSet

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

func (Client) LTrim

func (c Client) LTrim(ctx context.Context, key string, start, stop int64) *StatusCmd

func (Client) LastSave

func (c Client) LastSave(ctx context.Context) *IntCmd

func (Client) MGet

func (c Client) MGet(ctx context.Context, keys ...string) *SliceCmd

func (Client) MSet

func (c Client) MSet(ctx context.Context, values ...interface{}) *StatusCmd

MSet is like Set but accepts multiple values:

- MSet("key1", "value1", "key2", "value2")
- MSet([]string{"key1", "value1", "key2", "value2"})
- MSet(map[string]interface{}{"key1": "value1", "key2": "value2"})

func (Client) MSetNX

func (c Client) MSetNX(ctx context.Context, values ...interface{}) *BoolCmd

MSetNX is like SetNX but accepts multiple values:

- MSetNX("key1", "value1", "key2", "value2")
- MSetNX([]string{"key1", "value1", "key2", "value2"})
- MSetNX(map[string]interface{}{"key1": "value1", "key2": "value2"})

func (Client) MemoryUsage

func (c Client) MemoryUsage(ctx context.Context, key string, samples ...int) *IntCmd

func (Client) Migrate

func (c Client) Migrate(ctx context.Context, host, port, key string, db int, timeout time.Duration) *StatusCmd

func (Client) Move

func (c Client) Move(ctx context.Context, key string, db int) *BoolCmd

func (Client) ObjectEncoding

func (c Client) ObjectEncoding(ctx context.Context, key string) *StringCmd

func (Client) ObjectIdleTime

func (c Client) ObjectIdleTime(ctx context.Context, key string) *DurationCmd

func (Client) ObjectRefCount

func (c Client) ObjectRefCount(ctx context.Context, 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(ctx context.Context, key string, expiration time.Duration) *BoolCmd

func (Client) PExpireAt

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

func (Client) PFAdd

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

func (Client) PFCount

func (c Client) PFCount(ctx context.Context, keys ...string) *IntCmd

func (Client) PFMerge

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

func (*Client) PSubscribe

func (c *Client) PSubscribe(ctx context.Context, 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(ctx context.Context, key string) *DurationCmd

func (Client) Persist

func (c Client) Persist(ctx context.Context, key string) *BoolCmd

func (Client) Ping

func (c Client) Ping(ctx context.Context) *StatusCmd

func (*Client) Pipeline

func (c *Client) Pipeline() Pipeliner
Example

Code:

pipe := rdb.Pipeline()

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

// Execute
//
//     INCR pipeline_counter
//     EXPIRE pipeline_counts 3600
//
// using one rdb-server roundtrip.
_, err := pipe.Exec(ctx)
fmt.Println(incr.Val(), err)
1 <nil>

func (*Client) Pipelined

func (c *Client) Pipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)
Example

Code:

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

func (*Client) PoolStats

func (c *Client) PoolStats() *PoolStats

PoolStats returns connection pool stats.

func (*Client) Process

func (c *Client) Process(ctx context.Context, cmd Cmder) error

func (Client) PubSubChannels

func (c Client) PubSubChannels(ctx context.Context, pattern string) *StringSliceCmd

func (Client) PubSubNumPat

func (c Client) PubSubNumPat(ctx context.Context) *IntCmd

func (Client) PubSubNumSub

func (c Client) PubSubNumSub(ctx context.Context, channels ...string) *StringIntMapCmd

func (Client) Publish

func (c Client) Publish(ctx context.Context, channel string, message interface{}) *IntCmd

Publish posts the message to the channel.

func (Client) Quit

func (c Client) Quit(ctx context.Context) *StatusCmd

func (Client) RPop

func (c Client) RPop(ctx context.Context, key string) *StringCmd

func (Client) RPopLPush

func (c Client) RPopLPush(ctx context.Context, source, destination string) *StringCmd

func (Client) RPush

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

func (Client) RPushX

func (c Client) RPushX(ctx context.Context, key string, values ...interface{}) *IntCmd

func (Client) RandomKey

func (c Client) RandomKey(ctx context.Context) *StringCmd

func (Client) ReadOnly

func (c Client) ReadOnly(ctx context.Context) *StatusCmd

func (Client) ReadWrite

func (c Client) ReadWrite(ctx context.Context) *StatusCmd

func (Client) Rename

func (c Client) Rename(ctx context.Context, key, newkey string) *StatusCmd

func (Client) RenameNX

func (c Client) RenameNX(ctx context.Context, key, newkey string) *BoolCmd

func (Client) Restore

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

func (Client) RestoreReplace

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

func (Client) SAdd

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

func (Client) SCard

func (c Client) SCard(ctx context.Context, key string) *IntCmd

func (Client) SDiff

func (c Client) SDiff(ctx context.Context, keys ...string) *StringSliceCmd

func (Client) SDiffStore

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

func (Client) SInter

func (c Client) SInter(ctx context.Context, keys ...string) *StringSliceCmd

func (Client) SInterStore

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

func (Client) SIsMember

func (c Client) SIsMember(ctx context.Context, key string, member interface{}) *BoolCmd

func (Client) SMembers

func (c Client) SMembers(ctx context.Context, key string) *StringSliceCmd

Redis `SMEMBERS key` command output as a slice.

func (Client) SMembersMap

func (c Client) SMembersMap(ctx context.Context, key string) *StringStructMapCmd

Redis `SMEMBERS key` command output as a map.

func (Client) SMove

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

func (Client) SPop

func (c Client) SPop(ctx context.Context, key string) *StringCmd

Redis `SPOP key` command.

func (Client) SPopN

func (c Client) SPopN(ctx context.Context, key string, count int64) *StringSliceCmd

Redis `SPOP key count` command.

func (Client) SRandMember

func (c Client) SRandMember(ctx context.Context, key string) *StringCmd

Redis `SRANDMEMBER key` command.

func (Client) SRandMemberN

func (c Client) SRandMemberN(ctx context.Context, key string, count int64) *StringSliceCmd

Redis `SRANDMEMBER key count` command.

func (Client) SRem

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

func (Client) SScan

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

func (Client) SUnion

func (c Client) SUnion(ctx context.Context, keys ...string) *StringSliceCmd

func (Client) SUnionStore

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

func (Client) Save

func (c Client) Save(ctx context.Context) *StatusCmd

func (Client) Scan

func (c Client) Scan(ctx context.Context, cursor uint64, match string, count int64) *ScanCmd
Example

Code:

rdb.FlushDB(ctx)
for i := 0; i < 33; i++ {
	err := rdb.Set(ctx, fmt.Sprintf("key%d", i), "value", 0).Err()
	if err != nil {
		panic(err)
	}
}

var cursor uint64
var n int
for {
	var keys []string
	var err error
	keys, cursor, err = rdb.Scan(ctx, cursor, "key*", 10).Result()
	if err != nil {
		panic(err)
	}
	n += len(keys)
	if cursor == 0 {
		break
	}
}

fmt.Printf("found %d keys\n", n)
found 33 keys

func (Client) ScriptExists

func (c Client) ScriptExists(ctx context.Context, hashes ...string) *BoolSliceCmd

func (Client) ScriptFlush

func (c Client) ScriptFlush(ctx context.Context) *StatusCmd

func (Client) ScriptKill

func (c Client) ScriptKill(ctx context.Context) *StatusCmd

func (Client) ScriptLoad

func (c Client) ScriptLoad(ctx context.Context, script string) *StringCmd

func (Client) Set

func (c Client) Set(ctx context.Context, 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. KeepTTL(-1) expiration is a Redis KEEPTTL option to keep existing TTL.

Example

Code:

// Last argument is expiration. Zero means the key has no
// expiration time.
err := rdb.Set(ctx, "key", "value", 0).Err()
if err != nil {
	panic(err)
}

// key2 will expire in an hour.
err = rdb.Set(ctx, "key2", "value", time.Hour).Err()
if err != nil {
	panic(err)
}

func (Client) SetBit

func (c Client) SetBit(ctx context.Context, key string, offset int64, value int) *IntCmd

func (Client) SetNX

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

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

Zero expiration means the key has no expiration time. KeepTTL(-1) expiration is a Redis KEEPTTL option to keep existing TTL.

func (Client) SetRange

func (c Client) SetRange(ctx context.Context, key string, offset int64, value string) *IntCmd

func (Client) SetXX

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

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

Zero expiration means the key has no expiration time. KeepTTL(-1) expiration is a Redis KEEPTTL option to keep existing TTL.

func (Client) Shutdown

func (c Client) Shutdown(ctx context.Context) *StatusCmd

func (Client) ShutdownNoSave

func (c Client) ShutdownNoSave(ctx context.Context) *StatusCmd

func (Client) ShutdownSave

func (c Client) ShutdownSave(ctx context.Context) *StatusCmd

func (Client) SlaveOf

func (c Client) SlaveOf(ctx context.Context, host, port string) *StatusCmd

func (Client) SlowLogGet

func (c Client) SlowLogGet(ctx context.Context, num int64) *SlowLogCmd
Example

Code:

const key = "slowlog-log-slower-than"

old := rdb.ConfigGet(ctx, key).Val()
rdb.ConfigSet(ctx, key, "0")
defer rdb.ConfigSet(ctx, key, old[1].(string))

if err := rdb.Do(ctx, "slowlog", "reset").Err(); err != nil {
	panic(err)
}

rdb.Set(ctx, "test", "true", 0)

result, err := rdb.SlowLogGet(ctx, -1).Result()
if err != nil {
	panic(err)
}
fmt.Println(len(result))
2

func (Client) Sort

func (c Client) Sort(ctx context.Context, key string, sort *Sort) *StringSliceCmd

func (Client) SortInterfaces

func (c Client) SortInterfaces(ctx context.Context, key string, sort *Sort) *SliceCmd

func (Client) SortStore

func (c Client) SortStore(ctx context.Context, key, store string, sort *Sort) *IntCmd

func (Client) StrLen

func (c Client) StrLen(ctx context.Context, key string) *IntCmd

func (Client) String

func (c Client) String() string

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, channels ...string) *PubSub

Subscribe subscribes the client to the specified channels. Channels can be omitted to create empty subscription. Note that this method does not wait on a response from Redis, so the subscription may not be active immediately. To force the connection to wait, you may call the Receive() method on the returned *PubSub like so:

sub := client.Subscribe(queryResp)
iface, err := sub.Receive()
if err != nil {
    // handle error
}

// Should be *Subscription, but others are possible if other actions have been
// taken on sub since it was created.
switch iface.(type) {
case *Subscription:
    // subscribe succeeded
case *Message:
    // received first message
case *Pong:
    // pong received
default:
    // handle error
}

ch := sub.Channel()

func (Client) Sync

func (c Client) Sync(ctx context.Context)

func (Client) TTL

func (c Client) TTL(ctx context.Context, key string) *DurationCmd

func (Client) Time

func (c Client) Time(ctx context.Context) *TimeCmd

func (Client) Touch

func (c Client) Touch(ctx context.Context, keys ...string) *IntCmd

func (*Client) TxPipeline

func (c *Client) TxPipeline() Pipeliner

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

Example

Code:

pipe := rdb.TxPipeline()

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

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

func (*Client) TxPipelined

func (c *Client) TxPipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)
Example

Code:

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

func (Client) Type

func (c Client) Type(ctx context.Context, key string) *StatusCmd
func (c Client) Unlink(ctx context.Context, keys ...string) *IntCmd

func (Client) Wait

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

func (*Client) Watch

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

Watch prepares a transaction and marks the keys to be watched for conditional execution if there are any keys.

The transaction is automatically closed when fn exits.

Example

Code:

const maxRetries = 1000

// Increment transactionally increments key using GET and SET commands.
increment := func(key string) error {
	// Transactional function.
	txf := func(tx *redis.Tx) error {
		// Get current value or zero.
		n, err := tx.Get(ctx, key).Int()
		if err != nil && err != redis.Nil {
			return err
		}

		// Actual opperation (local in optimistic lock).
		n++

		// Operation is commited only if the watched keys remain unchanged.
		_, err = tx.TxPipelined(ctx, func(pipe redis.Pipeliner) error {
			pipe.Set(ctx, key, n, 0)
			return nil
		})
		return err
	}

	for i := 0; i < maxRetries; i++ {
		err := rdb.Watch(ctx, txf, key)
		if err == nil {
			// Success.
			return nil
		}
		if err == redis.TxFailedErr {
			// Optimistic lock lost. Retry.
			continue
		}
		// Return any other error.
		return err
	}

	return errors.New("increment reached maximum number of retries")
}

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

		if err := increment("counter3"); err != nil {
			fmt.Println("increment error:", err)
		}
	}()
}
wg.Wait()

n, err := rdb.Get(ctx, "counter3").Int()
fmt.Println("ended with", n, err)
ended with 100 <nil>
Example (Instrumentation)

Code:

rdb := redis.NewClient(&redis.Options{
	Addr: ":6379",
})
rdb.AddHook(redisHook{})

rdb.Watch(ctx, func(tx *redis.Tx) error {
	tx.Ping(ctx)
	tx.Ping(ctx)
	return nil
}, "foo")
starting processing: <watch foo: >
finished processing: <watch foo: OK>
starting processing: <ping: >
finished processing: <ping: PONG>
starting processing: <ping: >
finished processing: <ping: PONG>
starting processing: <unwatch: >
finished processing: <unwatch: OK>

func (*Client) WithContext

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

func (*Client) WithTimeout

func (c *Client) WithTimeout(timeout time.Duration) *Client

func (Client) XAck

func (c Client) XAck(ctx context.Context, stream, group string, ids ...string) *IntCmd

func (Client) XAdd

func (c Client) XAdd(ctx context.Context, a *XAddArgs) *StringCmd

func (Client) XClaim

func (c Client) XClaim(ctx context.Context, a *XClaimArgs) *XMessageSliceCmd

func (Client) XClaimJustID

func (c Client) XClaimJustID(ctx context.Context, a *XClaimArgs) *StringSliceCmd

func (Client) XDel

func (c Client) XDel(ctx context.Context, stream string, ids ...string) *IntCmd

func (Client) XGroupCreate

func (c Client) XGroupCreate(ctx context.Context, stream, group, start string) *StatusCmd

func (Client) XGroupCreateMkStream

func (c Client) XGroupCreateMkStream(ctx context.Context, stream, group, start string) *StatusCmd

func (Client) XGroupDelConsumer

func (c Client) XGroupDelConsumer(ctx context.Context, stream, group, consumer string) *IntCmd

func (Client) XGroupDestroy

func (c Client) XGroupDestroy(ctx context.Context, stream, group string) *IntCmd

func (Client) XGroupSetID

func (c Client) XGroupSetID(ctx context.Context, stream, group, start string) *StatusCmd

func (Client) XInfoGroups

func (c Client) XInfoGroups(ctx context.Context, key string) *XInfoGroupsCmd

func (Client) XInfoStream

func (c Client) XInfoStream(ctx context.Context, key string) *XInfoStreamCmd

func (Client) XLen

func (c Client) XLen(ctx context.Context, stream string) *IntCmd

func (Client) XPending

func (c Client) XPending(ctx context.Context, stream, group string) *XPendingCmd

func (Client) XPendingExt

func (c Client) XPendingExt(ctx context.Context, a *XPendingExtArgs) *XPendingExtCmd

func (Client) XRange

func (c Client) XRange(ctx context.Context, stream, start, stop string) *XMessageSliceCmd

func (Client) XRangeN

func (c Client) XRangeN(ctx context.Context, stream, start, stop string, count int64) *XMessageSliceCmd

func (Client) XRead

func (c Client) XRead(ctx context.Context, a *XReadArgs) *XStreamSliceCmd

func (Client) XReadGroup

func (c Client) XReadGroup(ctx context.Context, a *XReadGroupArgs) *XStreamSliceCmd

func (Client) XReadStreams

func (c Client) XReadStreams(ctx context.Context, streams ...string) *XStreamSliceCmd

func (Client) XRevRange

func (c Client) XRevRange(ctx context.Context, stream, start, stop string) *XMessageSliceCmd

func (Client) XRevRangeN

func (c Client) XRevRangeN(ctx context.Context, stream, start, stop string, count int64) *XMessageSliceCmd

func (Client) XTrim

func (c Client) XTrim(ctx context.Context, key string, maxLen int64) *IntCmd

func (Client) XTrimApprox

func (c Client) XTrimApprox(ctx context.Context, key string, maxLen int64) *IntCmd

func (Client) ZAdd

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

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

func (Client) ZAddCh

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

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

func (Client) ZAddNX

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

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

func (Client) ZAddNXCh

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

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

func (Client) ZAddXX

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

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

func (Client) ZAddXXCh

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

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

func (Client) ZCard

func (c Client) ZCard(ctx context.Context, key string) *IntCmd

func (Client) ZCount

func (c Client) ZCount(ctx context.Context, key, min, max string) *IntCmd

func (Client) ZIncr

func (c Client) ZIncr(ctx context.Context, key string, member *Z) *FloatCmd

Redis `ZADD key INCR score member` command.

func (Client) ZIncrBy

func (c Client) ZIncrBy(ctx context.Context, key string, increment float64, member string) *FloatCmd

func (Client) ZIncrNX

func (c Client) ZIncrNX(ctx context.Context, key string, member *Z) *FloatCmd

Redis `ZADD key NX INCR score member` command.

func (Client) ZIncrXX

func (c Client) ZIncrXX(ctx context.Context, key string, member *Z) *FloatCmd

Redis `ZADD key XX INCR score member` command.

func (Client) ZInterStore

func (c Client) ZInterStore(ctx context.Context, destination string, store *ZStore) *IntCmd

func (Client) ZLexCount

func (c Client) ZLexCount(ctx context.Context, key, min, max string) *IntCmd

func (Client) ZPopMax

func (c Client) ZPopMax(ctx context.Context, key string, count ...int64) *ZSliceCmd

func (Client) ZPopMin

func (c Client) ZPopMin(ctx context.Context, key string, count ...int64) *ZSliceCmd

func (Client) ZRange

func (c Client) ZRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd

func (Client) ZRangeByLex

func (c Client) ZRangeByLex(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd

func (Client) ZRangeByScore

func (c Client) ZRangeByScore(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd

func (Client) ZRangeByScoreWithScores

func (c Client) ZRangeByScoreWithScores(ctx context.Context, key string, opt *ZRangeBy) *ZSliceCmd

func (Client) ZRangeWithScores

func (c Client) ZRangeWithScores(ctx context.Context, key string, start, stop int64) *ZSliceCmd

func (Client) ZRank

func (c Client) ZRank(ctx context.Context, key, member string) *IntCmd

func (Client) ZRem

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

func (Client) ZRemRangeByLex

func (c Client) ZRemRangeByLex(ctx context.Context, key, min, max string) *IntCmd

func (Client) ZRemRangeByRank

func (c Client) ZRemRangeByRank(ctx context.Context, key string, start, stop int64) *IntCmd

func (Client) ZRemRangeByScore

func (c Client) ZRemRangeByScore(ctx context.Context, key, min, max string) *IntCmd

func (Client) ZRevRange

func (c Client) ZRevRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd

func (Client) ZRevRangeByLex

func (c Client) ZRevRangeByLex(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd

func (Client) ZRevRangeByScore

func (c Client) ZRevRangeByScore(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd

func (Client) ZRevRangeByScoreWithScores

func (c Client) ZRevRangeByScoreWithScores(ctx context.Context, key string, opt *ZRangeBy) *ZSliceCmd

func (Client) ZRevRangeWithScores

func (c Client) ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) *ZSliceCmd

func (Client) ZRevRank

func (c Client) ZRevRank(ctx context.Context, key, member string) *IntCmd

func (Client) ZScan

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

func (Client) ZScore

func (c Client) ZScore(ctx context.Context, key, member string) *FloatCmd

func (Client) ZUnionStore

func (c Client) ZUnionStore(ctx context.Context, dest string, store *ZStore) *IntCmd

type ClusterClient

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

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

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.
rdb := redis.NewClusterClient(&redis.ClusterOptions{
	Addrs: []string{":7000", ":7001", ":7002", ":7003", ":7004", ":7005"},
})
rdb.Ping(ctx)
Example (ManualSetup)

Following example creates a cluster from 2 master nodes and 2 slave nodes without using cluster mode or Redis Sentinel.

Code:

// clusterSlots returns cluster slots information.
// It can use service like ZooKeeper to maintain configuration information
// and Cluster.ReloadState to manually trigger state reloading.
clusterSlots := func(ctx context.Context) ([]redis.ClusterSlot, error) {
	slots := []redis.ClusterSlot{
		// First node with 1 master and 1 slave.
		{
			Start: 0,
			End:   8191,
			Nodes: []redis.ClusterNode{{
				Addr: ":7000", // master
			}, {
				Addr: ":8000", // 1st slave
			}},
		},
		// Second node with 1 master and 1 slave.
		{
			Start: 8192,
			End:   16383,
			Nodes: []redis.ClusterNode{{
				Addr: ":7001", // master
			}, {
				Addr: ":8001", // 1st slave
			}},
		},
	}
	return slots, nil
}

rdb := redis.NewClusterClient(&redis.ClusterOptions{
	ClusterSlots:  clusterSlots,
	RouteRandomly: true,
})
rdb.Ping(ctx)

// ReloadState reloads cluster state. It calls ClusterSlots func
// to get cluster slots information.
rdb.ReloadState(ctx)

func NewFailoverClusterClient

func NewFailoverClusterClient(failoverOpt *FailoverOptions) *ClusterClient

NewFailoverClusterClient returns a client that supports routing read-only commands to a slave node.

func (*ClusterClient) AddHook

func (hs *ClusterClient) AddHook(hook Hook)

func (ClusterClient) Append

func (c ClusterClient) Append(ctx context.Context, key, value string) *IntCmd

func (ClusterClient) BLPop

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

func (ClusterClient) BRPop

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

func (ClusterClient) BRPopLPush

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

func (ClusterClient) BZPopMax

func (c ClusterClient) BZPopMax(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd

Redis `BZPOPMAX key [key ...] timeout` command.

func (ClusterClient) BZPopMin

func (c ClusterClient) BZPopMin(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd

Redis `BZPOPMIN key [key ...] timeout` command.

func (ClusterClient) BgRewriteAOF

func (c ClusterClient) BgRewriteAOF(ctx context.Context) *StatusCmd

func (ClusterClient) BgSave

func (c ClusterClient) BgSave(ctx context.Context) *StatusCmd

func (ClusterClient) BitCount

func (c ClusterClient) BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd

func (ClusterClient) BitField

func (c ClusterClient) BitField(ctx context.Context, key string, args ...interface{}) *IntSliceCmd

func (ClusterClient) BitOpAnd

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

func (ClusterClient) BitOpNot

func (c ClusterClient) BitOpNot(ctx context.Context, destKey string, key string) *IntCmd

func (ClusterClient) BitOpOr

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

func (ClusterClient) BitOpXor

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

func (ClusterClient) BitPos

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

func (ClusterClient) ClientGetName

func (c ClusterClient) ClientGetName(ctx context.Context) *StringCmd

ClientGetName returns the name of the connection.

func (ClusterClient) ClientID

func (c ClusterClient) ClientID(ctx context.Context) *IntCmd

func (ClusterClient) ClientKill

func (c ClusterClient) ClientKill(ctx context.Context, ipPort string) *StatusCmd

func (ClusterClient) ClientKillByFilter

func (c ClusterClient) ClientKillByFilter(ctx context.Context, keys ...string) *IntCmd

ClientKillByFilter is new style syntax, while the ClientKill is old

CLIENT KILL <option> [value] ... <option> [value]

func (ClusterClient) ClientList

func (c ClusterClient) ClientList(ctx context.Context) *StringCmd

func (ClusterClient) ClientPause

func (c ClusterClient) ClientPause(ctx context.Context, dur time.Duration) *BoolCmd

func (ClusterClient) ClientUnblock

func (c ClusterClient) ClientUnblock(ctx context.Context, id int64) *IntCmd

func (ClusterClient) ClientUnblockWithError

func (c ClusterClient) ClientUnblockWithError(ctx context.Context, id int64) *IntCmd

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(ctx context.Context, slots ...int) *StatusCmd

func (ClusterClient) ClusterAddSlotsRange

func (c ClusterClient) ClusterAddSlotsRange(ctx context.Context, min, max int) *StatusCmd

func (ClusterClient) ClusterCountFailureReports

func (c ClusterClient) ClusterCountFailureReports(ctx context.Context, nodeID string) *IntCmd

func (ClusterClient) ClusterCountKeysInSlot

func (c ClusterClient) ClusterCountKeysInSlot(ctx context.Context, slot int) *IntCmd

func (ClusterClient) ClusterDelSlots

func (c ClusterClient) ClusterDelSlots(ctx context.Context, slots ...int) *StatusCmd

func (ClusterClient) ClusterDelSlotsRange

func (c ClusterClient) ClusterDelSlotsRange(ctx context.Context, min, max int) *StatusCmd

func (ClusterClient) ClusterFailover

func (c ClusterClient) ClusterFailover(ctx context.Context) *StatusCmd

func (ClusterClient) ClusterForget

func (c ClusterClient) ClusterForget(ctx context.Context, nodeID string) *StatusCmd

func (ClusterClient) ClusterGetKeysInSlot

func (c ClusterClient) ClusterGetKeysInSlot(ctx context.Context, slot int, count int) *StringSliceCmd

func (ClusterClient) ClusterInfo

func (c ClusterClient) ClusterInfo(ctx context.Context) *StringCmd

func (ClusterClient) ClusterKeySlot

func (c ClusterClient) ClusterKeySlot(ctx context.Context, key string) *IntCmd

func (ClusterClient) ClusterMeet

func (c ClusterClient) ClusterMeet(ctx context.Context, host, port string) *StatusCmd

func (ClusterClient) ClusterNodes

func (c ClusterClient) ClusterNodes(ctx context.Context) *StringCmd

func (ClusterClient) ClusterReplicate

func (c ClusterClient) ClusterReplicate(ctx context.Context, nodeID string) *StatusCmd

func (ClusterClient) ClusterResetHard

func (c ClusterClient) ClusterResetHard(ctx context.Context) *StatusCmd

func (ClusterClient) ClusterResetSoft

func (c ClusterClient) ClusterResetSoft(ctx context.Context) *StatusCmd

func (ClusterClient) ClusterSaveConfig

func (c ClusterClient) ClusterSaveConfig(ctx context.Context) *StatusCmd

func (ClusterClient) ClusterSlaves

func (c ClusterClient) ClusterSlaves(ctx context.Context, nodeID string) *StringSliceCmd

func (ClusterClient) ClusterSlots

func (c ClusterClient) ClusterSlots(ctx context.Context) *ClusterSlotsCmd

func (ClusterClient) Command

func (c ClusterClient) Command(ctx context.Context) *CommandsInfoCmd

func (ClusterClient) ConfigGet

func (c ClusterClient) ConfigGet(ctx context.Context, parameter string) *SliceCmd

func (ClusterClient) ConfigResetStat

func (c ClusterClient) ConfigResetStat(ctx context.Context) *StatusCmd

func (ClusterClient) ConfigRewrite

func (c ClusterClient) ConfigRewrite(ctx context.Context) *StatusCmd

func (ClusterClient) ConfigSet

func (c ClusterClient) ConfigSet(ctx context.Context, parameter, value string) *StatusCmd

func (*ClusterClient) Context

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

func (*ClusterClient) DBSize

func (c *ClusterClient) DBSize(ctx context.Context) *IntCmd

func (ClusterClient) DebugObject

func (c ClusterClient) DebugObject(ctx context.Context, key string) *StringCmd

func (ClusterClient) Decr

func (c ClusterClient) Decr(ctx context.Context, key string) *IntCmd

func (ClusterClient) DecrBy

func (c ClusterClient) DecrBy(ctx context.Context, key string, decrement int64) *IntCmd

func (ClusterClient) Del

func (c ClusterClient) Del(ctx context.Context, keys ...string) *IntCmd

func (*ClusterClient) Do

func (c *ClusterClient) Do(ctx context.Context, args ...interface{}) *Cmd

Do creates a Cmd from the args and processes the cmd.

func (ClusterClient) Dump

func (c ClusterClient) Dump(ctx context.Context, key string) *StringCmd

func (ClusterClient) Echo

func (c ClusterClient) Echo(ctx context.Context, message interface{}) *StringCmd

func (ClusterClient) Eval

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

func (ClusterClient) EvalSha

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

func (ClusterClient) Exists

func (c ClusterClient) Exists(ctx context.Context, keys ...string) *IntCmd

func (ClusterClient) Expire

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

func (ClusterClient) ExpireAt

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

func (ClusterClient) FlushAll

func (c ClusterClient) FlushAll(ctx context.Context) *StatusCmd

func (ClusterClient) FlushAllAsync

func (c ClusterClient) FlushAllAsync(ctx context.Context) *StatusCmd

func (ClusterClient) FlushDB

func (c ClusterClient) FlushDB(ctx context.Context) *StatusCmd

func (ClusterClient) FlushDBAsync

func (c ClusterClient) FlushDBAsync(ctx context.Context) *StatusCmd

func (*ClusterClient) ForEachMaster

func (c *ClusterClient) ForEachMaster(
	ctx context.Context,
	fn func(ctx context.Context, 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) ForEachShard

func (c *ClusterClient) ForEachShard(
	ctx context.Context,
	fn func(ctx context.Context, client *Client) error,
) error

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

func (*ClusterClient) ForEachSlave

func (c *ClusterClient) ForEachSlave(
	ctx context.Context,
	fn func(ctx context.Context, client *Client) error,
) error

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

func (ClusterClient) GeoAdd

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

func (ClusterClient) GeoDist

func (c ClusterClient) GeoDist(
	ctx context.Context, key string, member1, member2, unit string,
) *FloatCmd

func (ClusterClient) GeoHash

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

func (ClusterClient) GeoPos

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

func (ClusterClient) GeoRadius

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

GeoRadius is a read-only GEORADIUS_RO command.

func (ClusterClient) GeoRadiusByMember

func (c ClusterClient) GeoRadiusByMember(
	ctx context.Context, key, member string, query *GeoRadiusQuery,
) *GeoLocationCmd

GeoRadius is a read-only GEORADIUSBYMEMBER_RO command.

func (ClusterClient) GeoRadiusByMemberStore

func (c ClusterClient) GeoRadiusByMemberStore(
	ctx context.Context, key, member string, query *GeoRadiusQuery,
) *IntCmd

GeoRadiusByMemberStore is a writing GEORADIUSBYMEMBER command.

func (ClusterClient) GeoRadiusStore

func (c ClusterClient) GeoRadiusStore(
	ctx context.Context, key string, longitude, latitude float64, query *GeoRadiusQuery,
) *IntCmd

GeoRadiusStore is a writing GEORADIUS command.

func (ClusterClient) Get

func (c ClusterClient) Get(ctx context.Context, key string) *StringCmd

Redis `GET key` command. It returns redis.Nil error when key does not exist.

func (ClusterClient) GetBit

func (c ClusterClient) GetBit(ctx context.Context, key string, offset int64) *IntCmd

func (ClusterClient) GetRange

func (c ClusterClient) GetRange(ctx context.Context, key string, start, end int64) *StringCmd

func (ClusterClient) GetSet

func (c ClusterClient) GetSet(ctx context.Context, key string, value interface{}) *StringCmd

func (ClusterClient) HDel

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

func (ClusterClient) HExists

func (c ClusterClient) HExists(ctx context.Context, key, field string) *BoolCmd

func (ClusterClient) HGet

func (c ClusterClient) HGet(ctx context.Context, key, field string) *StringCmd

func (ClusterClient) HGetAll

func (c ClusterClient) HGetAll(ctx context.Context, key string) *StringStringMapCmd

func (ClusterClient) HIncrBy

func (c ClusterClient) HIncrBy(ctx context.Context, key, field string, incr int64) *IntCmd

func (ClusterClient) HIncrByFloat

func (c ClusterClient) HIncrByFloat(ctx context.Context, key, field string, incr float64) *FloatCmd

func (ClusterClient) HKeys

func (c ClusterClient) HKeys(ctx context.Context, key string) *StringSliceCmd

func (ClusterClient) HLen

func (c ClusterClient) HLen(ctx context.Context, key string) *IntCmd

func (ClusterClient) HMGet

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

HMGet returns the values for the specified fields in the hash stored at key. It returns an interface{} to distinguish between empty string and nil value.

func (ClusterClient) HMSet

func (c ClusterClient) HMSet(ctx context.Context, key string, values ...interface{}) *BoolCmd

HMSet is a deprecated version of HSet left for compatibility with Redis 3.

func (ClusterClient) HScan

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

func (ClusterClient) HSet

func (c ClusterClient) HSet(ctx context.Context, key string, values ...interface{}) *IntCmd

HSet accepts values in following formats:

- HSet("myhash", "key1", "value1", "key2", "value2")
- HSet("myhash", []string{"key1", "value1", "key2", "value2"})
- HSet("myhash", map[string]interface{}{"key1": "value1", "key2": "value2"})

Note that it requires Redis v4 for multiple field/value pairs support.

func (ClusterClient) HSetNX

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

func (ClusterClient) HVals

func (c ClusterClient) HVals(ctx context.Context, key string) *StringSliceCmd

func (ClusterClient) Incr

func (c ClusterClient) Incr(ctx context.Context, key string) *IntCmd

func (ClusterClient) IncrBy

func (c ClusterClient) IncrBy(ctx context.Context, key string, value int64) *IntCmd

func (ClusterClient) IncrByFloat

func (c ClusterClient) IncrByFloat(ctx context.Context, key string, value float64) *FloatCmd

func (ClusterClient) Info

func (c ClusterClient) Info(ctx context.Context, section ...string) *StringCmd

func (ClusterClient) Keys

func (c ClusterClient) Keys(ctx context.Context, pattern string) *StringSliceCmd

func (ClusterClient) LIndex

func (c ClusterClient) LIndex(ctx context.Context, key string, index int64) *StringCmd

func (ClusterClient) LInsert

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

func (ClusterClient) LInsertAfter

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

func (ClusterClient) LInsertBefore

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

func (ClusterClient) LLen

func (c ClusterClient) LLen(ctx context.Context, key string) *IntCmd

func (ClusterClient) LPop

func (c ClusterClient) LPop(ctx context.Context, key string) *StringCmd

func (ClusterClient) LPush

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

func (ClusterClient) LPushX

func (c ClusterClient) LPushX(ctx context.Context, key string, values ...interface{}) *IntCmd

func (ClusterClient) LRange

func (c ClusterClient) LRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd

func (ClusterClient) LRem

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

func (ClusterClient) LSet

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

func (ClusterClient) LTrim

func (c ClusterClient) LTrim(ctx context.Context, key string, start, stop int64) *StatusCmd

func (ClusterClient) LastSave

func (c ClusterClient) LastSave(ctx context.Context) *IntCmd

func (ClusterClient) MGet

func (c ClusterClient) MGet(ctx context.Context, keys ...string) *SliceCmd

func (ClusterClient) MSet

func (c ClusterClient) MSet(ctx context.Context, values ...interface{}) *StatusCmd

MSet is like Set but accepts multiple values:

- MSet("key1", "value1", "key2", "value2")
- MSet([]string{"key1", "value1", "key2", "value2"})
- MSet(map[string]interface{}{"key1": "value1", "key2": "value2"})

func (ClusterClient) MSetNX

func (c ClusterClient) MSetNX(ctx context.Context, values ...interface{}) *BoolCmd

MSetNX is like SetNX but accepts multiple values:

- MSetNX("key1", "value1", "key2", "value2")
- MSetNX([]string{"key1", "value1", "key2", "value2"})
- MSetNX(map[string]interface{}{"key1": "value1", "key2": "value2"})

func (ClusterClient) MemoryUsage

func (c ClusterClient) MemoryUsage(ctx context.Context, key string, samples ...int) *IntCmd

func (ClusterClient) Migrate

func (c ClusterClient) Migrate(ctx context.Context, host, port, key string, db int, timeout time.Duration) *StatusCmd

func (ClusterClient) Move

func (c ClusterClient) Move(ctx context.Context, key string, db int) *BoolCmd

func (ClusterClient) ObjectEncoding

func (c ClusterClient) ObjectEncoding(ctx context.Context, key string) *StringCmd

func (ClusterClient) ObjectIdleTime

func (c ClusterClient) ObjectIdleTime(ctx context.Context, key string) *DurationCmd

func (ClusterClient) ObjectRefCount

func (c ClusterClient) ObjectRefCount(ctx context.Context, 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(ctx context.Context, key string, expiration time.Duration) *BoolCmd

func (ClusterClient) PExpireAt

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

func (ClusterClient) PFAdd

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

func (ClusterClient) PFCount

func (c ClusterClient) PFCount(ctx context.Context, keys ...string) *IntCmd

func (ClusterClient) PFMerge

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

func (*ClusterClient) PSubscribe

func (c *ClusterClient) PSubscribe(ctx context.Context, channels ...string) *PubSub

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

func (ClusterClient) PTTL

func (c ClusterClient) PTTL(ctx context.Context, key string) *DurationCmd

func (ClusterClient) Persist

func (c ClusterClient) Persist(ctx context.Context, key string) *BoolCmd

func (ClusterClient) Ping

func (c ClusterClient) Ping(ctx context.Context) *StatusCmd

func (*ClusterClient) Pipeline

func (c *ClusterClient) Pipeline() Pipeliner

func (*ClusterClient) Pipelined

func (c *ClusterClient) Pipelined(ctx context.Context, 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(ctx context.Context, cmd Cmder) error

func (ClusterClient) PubSubChannels

func (c ClusterClient) PubSubChannels(ctx context.Context, pattern string) *StringSliceCmd

func (ClusterClient) PubSubNumPat

func (c ClusterClient) PubSubNumPat(ctx context.Context) *IntCmd

func (ClusterClient) PubSubNumSub

func (c ClusterClient) PubSubNumSub(ctx context.Context, channels ...string) *StringIntMapCmd

func (ClusterClient) Publish

func (c ClusterClient) Publish(ctx context.Context, channel string, message interface{}) *IntCmd

Publish posts the message to the channel.

func (ClusterClient) Quit

func (c ClusterClient) Quit(ctx context.Context) *StatusCmd

func (ClusterClient) RPop

func (c ClusterClient) RPop(ctx context.Context, key string) *StringCmd

func (ClusterClient) RPopLPush

func (c ClusterClient) RPopLPush(ctx context.Context, source, destination string) *StringCmd

func (ClusterClient) RPush

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

func (ClusterClient) RPushX

func (c ClusterClient) RPushX(ctx context.Context, key string, values ...interface{}) *IntCmd

func (ClusterClient) RandomKey

func (c ClusterClient) RandomKey(ctx context.Context) *StringCmd

func (ClusterClient) ReadOnly

func (c ClusterClient) ReadOnly(ctx context.Context) *StatusCmd

func (ClusterClient) ReadWrite

func (c ClusterClient) ReadWrite(ctx context.Context) *StatusCmd

func (*ClusterClient) ReloadState

func (c *ClusterClient) ReloadState(ctx context.Context)

ReloadState reloads cluster state. If available it calls ClusterSlots func to get cluster slots information.

func (ClusterClient) Rename

func (c ClusterClient) Rename(ctx context.Context, key, newkey string) *StatusCmd

func (ClusterClient) RenameNX

func (c ClusterClient) RenameNX(ctx context.Context, key, newkey string) *BoolCmd

func (ClusterClient) Restore

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

func (ClusterClient) RestoreReplace

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

func (ClusterClient) SAdd

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

func (ClusterClient) SCard

func (c ClusterClient) SCard(ctx context.Context, key string) *IntCmd

func (ClusterClient) SDiff

func (c ClusterClient) SDiff(ctx context.Context, keys ...string) *StringSliceCmd

func (ClusterClient) SDiffStore

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

func (ClusterClient) SInter

func (c ClusterClient) SInter(ctx context.Context, keys ...string) *StringSliceCmd

func (ClusterClient) SInterStore

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

func (ClusterClient) SIsMember

func (c ClusterClient) SIsMember(ctx context.Context, key string, member interface{}) *BoolCmd

func (ClusterClient) SMembers

func (c ClusterClient) SMembers(ctx context.Context, key string) *StringSliceCmd

Redis `SMEMBERS key` command output as a slice.

func (ClusterClient) SMembersMap

func (c ClusterClient) SMembersMap(ctx context.Context, key string) *StringStructMapCmd

Redis `SMEMBERS key` command output as a map.

func (ClusterClient) SMove

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

func (ClusterClient) SPop

func (c ClusterClient) SPop(ctx context.Context, key string) *StringCmd

Redis `SPOP key` command.

func (ClusterClient) SPopN

func (c ClusterClient) SPopN(ctx context.Context, key string, count int64) *StringSliceCmd

Redis `SPOP key count` command.

func (ClusterClient) SRandMember

func (c ClusterClient) SRandMember(ctx context.Context, key string) *StringCmd

Redis `SRANDMEMBER key` command.

func (ClusterClient) SRandMemberN

func (c ClusterClient) SRandMemberN(ctx context.Context, key string, count int64) *StringSliceCmd

Redis `SRANDMEMBER key count` command.

func (ClusterClient) SRem

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

func (ClusterClient) SScan

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

func (ClusterClient) SUnion

func (c ClusterClient) SUnion(ctx context.Context, keys ...string) *StringSliceCmd

func (ClusterClient) SUnionStore

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

func (ClusterClient) Save

func (c ClusterClient) Save(ctx context.Context) *StatusCmd

func (ClusterClient) Scan

func (c ClusterClient) Scan(ctx context.Context, cursor uint64, match string, count int64) *ScanCmd

func (ClusterClient) ScriptExists

func (c ClusterClient) ScriptExists(ctx context.Context, hashes ...string) *BoolSliceCmd

func (ClusterClient) ScriptFlush

func (c ClusterClient) ScriptFlush(ctx context.Context) *StatusCmd

func (ClusterClient) ScriptKill

func (c ClusterClient) ScriptKill(ctx context.Context) *StatusCmd

func (ClusterClient) ScriptLoad

func (c ClusterClient) ScriptLoad(ctx context.Context, script string) *StringCmd

func (ClusterClient) Set

func (c ClusterClient) Set(ctx context.Context, 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. KeepTTL(-1) expiration is a Redis KEEPTTL option to keep existing TTL.

func (ClusterClient) SetBit

func (c ClusterClient) SetBit(ctx context.Context, key string, offset int64, value int) *IntCmd

func (ClusterClient) SetNX

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

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

Zero expiration means the key has no expiration time. KeepTTL(-1) expiration is a Redis KEEPTTL option to keep existing TTL.

func (ClusterClient) SetRange

func (c ClusterClient) SetRange(ctx context.Context, key string, offset int64, value string) *IntCmd

func (ClusterClient) SetXX

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

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

Zero expiration means the key has no expiration time. KeepTTL(-1) expiration is a Redis KEEPTTL option to keep existing TTL.

func (ClusterClient) Shutdown

func (c ClusterClient) Shutdown(ctx context.Context) *StatusCmd

func (ClusterClient) ShutdownNoSave

func (c ClusterClient) ShutdownNoSave(ctx context.Context) *StatusCmd

func (ClusterClient) ShutdownSave

func (c ClusterClient) ShutdownSave(ctx context.Context) *StatusCmd

func (ClusterClient) SlaveOf

func (c ClusterClient) SlaveOf(ctx context.Context, host, port string) *StatusCmd

func (ClusterClient) SlowLogGet

func (c ClusterClient) SlowLogGet(ctx context.Context, num int64) *SlowLogCmd

func (ClusterClient) Sort

func (c ClusterClient) Sort(ctx context.Context, key string, sort *Sort) *StringSliceCmd

func (ClusterClient) SortInterfaces

func (c ClusterClient) SortInterfaces(ctx context.Context, key string, sort *Sort) *SliceCmd

func (ClusterClient) SortStore

func (c ClusterClient) SortStore(ctx context.Context, key, store string, sort *Sort) *IntCmd

func (ClusterClient) StrLen

func (c ClusterClient) StrLen(ctx context.Context, key string) *IntCmd

func (*ClusterClient) Subscribe

func (c *ClusterClient) Subscribe(ctx context.Context, channels ...string) *PubSub

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

func (ClusterClient) Sync

func (c ClusterClient) Sync(ctx context.Context)

func (ClusterClient) TTL

func (c ClusterClient) TTL(ctx context.Context, key string) *DurationCmd

func (ClusterClient) Time

func (c ClusterClient) Time(ctx context.Context) *TimeCmd

func (ClusterClient) Touch

func (c ClusterClient) Touch(ctx context.Context, keys ...string) *IntCmd

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(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)

func (ClusterClient) Type

func (c ClusterClient) Type(ctx context.Context, key string) *StatusCmd
func (c ClusterClient) Unlink(ctx context.Context, keys ...string) *IntCmd

func (ClusterClient) Wait

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

func (*ClusterClient) Watch

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

func (*ClusterClient) WithContext

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

func (ClusterClient) XAck

func (c ClusterClient) XAck(ctx context.Context, stream, group string, ids ...string) *IntCmd

func (ClusterClient) XAdd

func (c ClusterClient) XAdd(ctx context.Context, a *XAddArgs) *StringCmd

func (ClusterClient) XClaim

func (c ClusterClient) XClaim(ctx context.Context, a *XClaimArgs) *XMessageSliceCmd

func (ClusterClient) XClaimJustID

func (c ClusterClient) XClaimJustID(ctx context.Context, a *XClaimArgs) *StringSliceCmd

func (ClusterClient) XDel

func (c ClusterClient) XDel(ctx context.Context, stream string, ids ...string) *IntCmd

func (ClusterClient) XGroupCreate

func (c ClusterClient) XGroupCreate(ctx context.Context, stream, group, start string) *StatusCmd

func (ClusterClient) XGroupCreateMkStream

func (c ClusterClient) XGroupCreateMkStream(ctx context.Context, stream, group, start string) *StatusCmd

func (ClusterClient) XGroupDelConsumer

func (c ClusterClient) XGroupDelConsumer(ctx context.Context, stream, group, consumer string) *IntCmd

func (ClusterClient) XGroupDestroy

func (c ClusterClient) XGroupDestroy(ctx context.Context, stream, group string) *IntCmd

func (ClusterClient) XGroupSetID

func (c ClusterClient) XGroupSetID(ctx context.Context, stream, group, start string) *StatusCmd

func (ClusterClient) XInfoGroups

func (c ClusterClient) XInfoGroups(ctx context.Context, key string) *XInfoGroupsCmd

func (ClusterClient) XInfoStream

func (c ClusterClient) XInfoStream(ctx context.Context, key string) *XInfoStreamCmd

func (ClusterClient) XLen

func (c ClusterClient) XLen(ctx context.Context, stream string) *IntCmd

func (ClusterClient) XPending

func (c ClusterClient) XPending(ctx context.Context, stream, group string) *XPendingCmd

func (ClusterClient) XPendingExt

func (c ClusterClient) XPendingExt(ctx context.Context, a *XPendingExtArgs) *XPendingExtCmd

func (ClusterClient) XRange

func (c ClusterClient) XRange(ctx context.Context, stream, start, stop string) *XMessageSliceCmd

func (ClusterClient) XRangeN

func (c ClusterClient) XRangeN(ctx context.Context, stream, start, stop string, count int64) *XMessageSliceCmd

func (ClusterClient) XRead

func (c ClusterClient) XRead(ctx context.Context, a *XReadArgs) *XStreamSliceCmd

func (ClusterClient) XReadGroup

func (c ClusterClient) XReadGroup(ctx context.Context, a *XReadGroupArgs) *XStreamSliceCmd

func (ClusterClient) XReadStreams

func (c ClusterClient) XReadStreams(ctx context.Context, streams ...string) *XStreamSliceCmd

func (ClusterClient) XRevRange

func (c ClusterClient) XRevRange(ctx context.Context, stream, start, stop string) *XMessageSliceCmd

func (ClusterClient) XRevRangeN

func (c ClusterClient) XRevRangeN(ctx context.Context, stream, start, stop string, count int64) *XMessageSliceCmd

func (ClusterClient) XTrim

func (c ClusterClient) XTrim(ctx context.Context, key string, maxLen int64) *IntCmd

func (ClusterClient) XTrimApprox

func (c ClusterClient) XTrimApprox(ctx context.Context, key string, maxLen int64) *IntCmd

func (ClusterClient) ZAdd

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

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

func (ClusterClient) ZAddCh

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

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

func (ClusterClient) ZAddNX

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

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

func (ClusterClient) ZAddNXCh

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

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

func (ClusterClient) ZAddXX

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

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

func (ClusterClient) ZAddXXCh

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

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

func (ClusterClient) ZCard

func (c ClusterClient) ZCard(ctx context.Context, key string) *IntCmd

func (ClusterClient) ZCount

func (c ClusterClient) ZCount(ctx context.Context, key, min, max string) *IntCmd

func (ClusterClient) ZIncr

func (c ClusterClient) ZIncr(ctx context.Context, key string, member *Z) *FloatCmd

Redis `ZADD key INCR score member` command.

func (ClusterClient) ZIncrBy

func (c ClusterClient) ZIncrBy(ctx context.Context, key string, increment float64, member string) *FloatCmd

func (ClusterClient) ZIncrNX

func (c ClusterClient) ZIncrNX(ctx context.Context, key string, member *Z) *FloatCmd

Redis `ZADD key NX INCR score member` command.

func (ClusterClient) ZIncrXX

func (c ClusterClient) ZIncrXX(ctx context.Context, key string, member *Z) *FloatCmd

Redis `ZADD key XX INCR score member` command.

func (ClusterClient) ZInterStore

func (c ClusterClient) ZInterStore(ctx context.Context, destination string, store *ZStore) *IntCmd

func (ClusterClient) ZLexCount

func (c ClusterClient) ZLexCount(ctx context.Context, key, min, max string) *IntCmd

func (ClusterClient) ZPopMax

func (c ClusterClient) ZPopMax(ctx context.Context, key string, count ...int64) *ZSliceCmd

func (ClusterClient)