redis: github.com/go-redis/redis Index | Examples | Files | Directories

package redis

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

Package redis implements a Redis client.

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)

Output:

"" redis: nil

Code:

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

Output:

"" redis: nil

Code:

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

rdb.Ping(ctx)

Output:

starting processing: <ping: >
finished processing: <ping: PONG>

Index

Examples

Package Files

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

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 Uses

func SetLogger(logger internal.Logging)

type BitCount Uses

type BitCount struct {
    Start, End int64
}

type BoolCmd Uses

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

func NewBoolCmd Uses

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

func NewBoolResult Uses

func NewBoolResult(val bool, err error) *BoolCmd

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

func (*BoolCmd) Args Uses

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

func (*BoolCmd) Err Uses

func (cmd *BoolCmd) Err() error

func (*BoolCmd) FullName Uses

func (cmd *BoolCmd) FullName() string

func (*BoolCmd) Name Uses

func (cmd *BoolCmd) Name() string

func (*BoolCmd) Result Uses

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

func (*BoolCmd) SetErr Uses

func (cmd *BoolCmd) SetErr(e error)

func (*BoolCmd) String Uses

func (cmd *BoolCmd) String() string

func (*BoolCmd) Val Uses

func (cmd *BoolCmd) Val() bool

type BoolSliceCmd Uses

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

func NewBoolSliceCmd Uses

func NewBoolSliceCmd(ctx context.Context, args ...interface{}) *BoolSliceCmd

func NewBoolSliceResult Uses

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

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

func (*BoolSliceCmd) Args Uses

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

func (*BoolSliceCmd) Err Uses

func (cmd *BoolSliceCmd) Err() error

func (*BoolSliceCmd) FullName Uses

func (cmd *BoolSliceCmd) FullName() string

func (*BoolSliceCmd) Name Uses

func (cmd *BoolSliceCmd) Name() string

func (*BoolSliceCmd) Result Uses

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

func (*BoolSliceCmd) SetErr Uses

func (cmd *BoolSliceCmd) SetErr(e error)

func (*BoolSliceCmd) String Uses

func (cmd *BoolSliceCmd) String() string

func (*BoolSliceCmd) Val Uses

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

type Client Uses

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.

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)
}

Output:

key value
missing_key does not exist

func NewClient Uses

func NewClient(opt *Options) *Client

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

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)

Output:

PONG <nil>

func NewFailoverClient Uses

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.

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 Uses

func (hs *Client) AddHook(hook Hook)

func (Client) Append Uses

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

func (Client) BLPop Uses

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

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])

Output:

queue message

func (Client) BRPop Uses

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

func (Client) BRPopLPush Uses

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

func (Client) BZPopMax Uses

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

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

func (Client) BZPopMin Uses

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

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

func (Client) BgRewriteAOF Uses

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

func (Client) BgSave Uses

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

func (Client) BitCount Uses

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

func (Client) BitField Uses

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

func (Client) BitOpAnd Uses

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

func (Client) BitOpNot Uses

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

func (Client) BitOpOr Uses

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

func (Client) BitOpXor Uses

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

func (Client) BitPos Uses

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

func (Client) ClientGetName Uses

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

ClientGetName returns the name of the connection.

func (Client) ClientID Uses

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

func (Client) ClientKill Uses

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

func (Client) ClientKillByFilter Uses

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 Uses

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

func (Client) ClientPause Uses

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

func (Client) ClientUnblock Uses

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

func (Client) ClientUnblockWithError Uses

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

func (Client) Close Uses

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 Uses

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

func (Client) ClusterAddSlotsRange Uses

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

func (Client) ClusterCountFailureReports Uses

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

func (Client) ClusterCountKeysInSlot Uses

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

func (Client) ClusterDelSlots Uses

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

func (Client) ClusterDelSlotsRange Uses

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

func (Client) ClusterFailover Uses

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

func (Client) ClusterForget Uses

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

func (Client) ClusterGetKeysInSlot Uses

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

func (Client) ClusterInfo Uses

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

func (Client) ClusterKeySlot Uses

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

func (Client) ClusterMeet Uses

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

func (Client) ClusterNodes Uses

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

func (Client) ClusterReplicate Uses

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

func (Client) ClusterResetHard Uses

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

func (Client) ClusterResetSoft Uses

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

func (Client) ClusterSaveConfig Uses

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

func (Client) ClusterSlaves Uses

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

func (Client) ClusterSlots Uses

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

func (Client) Command Uses

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

func (Client) ConfigGet Uses

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

func (Client) ConfigResetStat Uses

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

func (Client) ConfigRewrite Uses

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

func (Client) ConfigSet Uses

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

func (*Client) Conn Uses

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

func (*Client) Context Uses

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

func (Client) DBSize Uses

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

func (Client) DebugObject Uses

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

func (Client) Decr Uses

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

func (Client) DecrBy Uses

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

func (Client) Del Uses

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

func (*Client) Do Uses

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

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

func (Client) Dump Uses

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

func (Client) Echo Uses

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

func (Client) Eval Uses

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

func (Client) EvalSha Uses

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

func (Client) Exists Uses

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

func (Client) Expire Uses

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

func (Client) ExpireAt Uses

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

func (Client) FlushAll Uses

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

func (Client) FlushAllAsync Uses

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

func (Client) FlushDB Uses

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

func (Client) FlushDBAsync Uses

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

func (Client) GeoAdd Uses

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

func (Client) GeoDist Uses

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

func (Client) GeoHash Uses

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

func (Client) GeoPos Uses

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

func (Client) GeoRadius Uses

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 Uses

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

GeoRadius is a read-only GEORADIUSBYMEMBER_RO command.

func (Client) GeoRadiusByMemberStore Uses

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

GeoRadiusByMemberStore is a writing GEORADIUSBYMEMBER command.

func (Client) GeoRadiusStore Uses

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

GeoRadiusStore is a writing GEORADIUS command.

func (Client) Get Uses

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 Uses

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

func (Client) GetRange Uses

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

func (Client) GetSet Uses

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

func (Client) HDel Uses

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

func (Client) HExists Uses

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

func (Client) HGet Uses

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

func (Client) HGetAll Uses

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

func (Client) HIncrBy Uses

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

func (Client) HIncrByFloat Uses

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

func (Client) HKeys Uses

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

func (Client) HLen Uses

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

func (Client) HMGet Uses

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 Uses

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 Uses

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

func (Client) HSet Uses

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 Uses

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

func (Client) HVals Uses

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

func (Client) Incr Uses

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

Code:

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

fmt.Println(result)

Output:

1

func (Client) IncrBy Uses

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

func (Client) IncrByFloat Uses

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

func (Client) Info Uses

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

func (Client) Keys Uses

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

func (Client) LIndex Uses

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

func (Client) LInsert Uses

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

func (Client) LInsertAfter Uses

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

func (Client) LInsertBefore Uses

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

func (Client) LLen Uses

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

func (Client) LPop Uses

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

func (Client) LPos Uses

func (c Client) LPos(ctx context.Context, key string, value string, a LPosArgs) *IntCmd

func (Client) LPosCount Uses

func (c Client) LPosCount(ctx context.Context, key string, value string, count int64, a LPosArgs) *IntSliceCmd

func (Client) LPush Uses

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

func (Client) LPushX Uses

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

func (Client) LRange Uses

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

func (Client) LRem Uses

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

func (Client) LSet Uses

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

func (Client) LTrim Uses

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

func (Client) LastSave Uses

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

func (Client) MGet Uses

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

func (Client) MSet Uses

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 Uses

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 Uses

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

func (Client) Migrate Uses

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

func (Client) Move Uses

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

func (Client) ObjectEncoding Uses

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

func (Client) ObjectIdleTime Uses

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

func (Client) ObjectRefCount Uses

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

func (*Client) Options Uses

func (c *Client) Options() *Options

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

func (Client) PExpire Uses

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

func (Client) PExpireAt Uses

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

func (Client) PFAdd Uses

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

func (Client) PFCount Uses

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

func (Client) PFMerge Uses

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

func (*Client) PSubscribe Uses

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 Uses

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

func (Client) Persist Uses

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

func (Client) Ping Uses

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

func (*Client) Pipeline Uses

func (c *Client) Pipeline() Pipeliner

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)

Output:

1 <nil>

func (*Client) Pipelined Uses

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

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)

Output:

1 <nil>

func (*Client) PoolStats Uses

func (c *Client) PoolStats() *PoolStats

PoolStats returns connection pool stats.

func (*Client) Process Uses

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

func (Client) PubSubChannels Uses

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

func (Client) PubSubNumPat Uses

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

func (Client) PubSubNumSub Uses

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

func (Client) Publish Uses

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

Publish posts the message to the channel.

func (Client) Quit Uses

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

func (Client) RPop Uses

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

func (Client) RPopLPush Uses

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

func (Client) RPush Uses

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

func (Client) RPushX Uses

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

func (Client) RandomKey Uses

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

func (Client) ReadOnly Uses

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

func (Client) ReadWrite Uses

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

func (Client) Rename Uses

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

func (Client) RenameNX Uses

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

func (Client) Restore Uses

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

func (Client) RestoreReplace Uses

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

func (Client) SAdd Uses

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

func (Client) SCard Uses

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

func (Client) SDiff Uses

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

func (Client) SDiffStore Uses

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

func (Client) SInter Uses

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

func (Client) SInterStore Uses

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

func (Client) SIsMember Uses

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

func (Client) SMembers Uses

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

Redis `SMEMBERS key` command output as a slice.

func (Client) SMembersMap Uses

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

Redis `SMEMBERS key` command output as a map.

func (Client) SMove Uses

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

func (Client) SPop Uses

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

Redis `SPOP key` command.

func (Client) SPopN Uses

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

Redis `SPOP key count` command.

func (Client) SRandMember Uses

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

Redis `SRANDMEMBER key` command.

func (Client) SRandMemberN Uses

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

Redis `SRANDMEMBER key count` command.

func (Client) SRem Uses

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

func (Client) SScan Uses

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

func (Client) SUnion Uses

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

func (Client) SUnionStore Uses

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

func (Client) Save Uses

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

func (Client) Scan Uses

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

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)

Output:

found 33 keys

func (Client) ScriptExists Uses

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

func (Client) ScriptFlush Uses

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

func (Client) ScriptKill Uses

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

func (Client) ScriptLoad Uses

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

func (Client) Set Uses

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.

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 Uses

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

func (Client) SetEX Uses

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

Redis `SETEX key expiration value` command.

Code:

err := rdb.SetEX(ctx, "key", "value", time.Hour).Err()
if err != nil {
    panic(err)
}

func (Client) SetNX Uses

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 Uses

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

func (Client) SetXX Uses

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 Uses

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

func (Client) ShutdownNoSave Uses

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

func (Client) ShutdownSave Uses

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

func (Client) SlaveOf Uses

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

func (Client) SlowLogGet Uses

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

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))

Output:

2

func (Client) Sort Uses

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

func (Client) SortInterfaces Uses

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

func (Client) SortStore Uses

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

func (Client) StrLen Uses

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

func (Client) String Uses

func (c Client) String() string

func (*Client) Subscribe Uses

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 Uses

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

func (Client) TTL Uses

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

func (Client) Time Uses

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

func (Client) Touch Uses

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

func (*Client) TxPipeline Uses

func (c *Client) TxPipeline() Pipeliner

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

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)

Output:

1 <nil>

func (*Client) TxPipelined Uses

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

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)

Output:

1 <nil>

func (Client) Type Uses

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

func (Client) Wait Uses

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

func (*Client) Watch Uses

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.

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)

Output:

ended with 100 <nil>

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")

Output:

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 Uses

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

func (*Client) WithTimeout Uses

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

func (Client) XAck Uses

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

func (Client) XAdd Uses

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

func (Client) XClaim Uses

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

func (Client) XClaimJustID Uses

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

func (Client) XDel Uses

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

func (Client) XGroupCreate Uses

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

func (Client) XGroupCreateMkStream Uses

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

func (Client) XGroupDelConsumer Uses

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

func (Client) XGroupDestroy Uses

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

func (Client) XGroupSetID Uses

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

func (Client) XInfoGroups Uses

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

func (Client) XInfoStream Uses

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

func (Client) XLen Uses

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

func (Client) XPending Uses

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

func (Client) XPendingExt Uses

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

func (Client) XRange Uses

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

func (Client) XRangeN Uses

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

func (Client) XRead Uses

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

func (Client) XReadGroup Uses

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

func (Client) XReadStreams Uses

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

func (Client) XRevRange Uses

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

func (Client) XRevRangeN Uses

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

func (Client) XTrim Uses

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

func (Client) XTrimApprox Uses

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

func (Client) ZAdd Uses

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

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

func (Client) ZAddCh Uses

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

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

func (Client) ZAddNX Uses

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

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

func (Client) ZAddNXCh Uses

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 Uses

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

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

func (Client) ZAddXXCh Uses

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 Uses

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

func (Client) ZCount Uses

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

func (Client) ZIncr Uses

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

Redis `ZADD key INCR score member` command.

func (Client) ZIncrBy Uses

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

func (Client) ZIncrNX Uses

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

Redis `ZADD key NX INCR score member` command.

func (Client) ZIncrXX Uses

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

Redis `ZADD key XX INCR score member` command.

func (Client) ZInterStore Uses

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

func (Client) ZLexCount Uses

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

func (Client) ZPopMax Uses

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

func (Client) ZPopMin Uses

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

func (Client) ZRange Uses

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

func (Client) ZRangeByLex Uses

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

func (Client) ZRangeByScore Uses

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

func (Client) ZRangeByScoreWithScores Uses

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

func (Client) ZRangeWithScores Uses

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

func (Client) ZRank Uses

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

func (Client) ZRem Uses

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

func (Client) ZRemRangeByLex Uses

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

func (Client) ZRemRangeByRank Uses

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

func (Client) ZRemRangeByScore Uses

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

func (Client) ZRevRange Uses

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

func (Client) ZRevRangeByLex Uses

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

func (Client) ZRevRangeByScore Uses

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

func (Client) ZRevRangeByScoreWithScores Uses

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

func (Client) ZRevRangeWithScores Uses

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

func (Client) ZRevRank Uses

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

func (Client) ZScan Uses

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

func (Client) ZScore Uses

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

func (Client) ZUnionStore Uses

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

type ClusterClient Uses

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 Uses

func NewClusterClient(opt *ClusterOptions) *ClusterClient

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

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)

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 Uses

func NewFailoverClusterClient(failoverOpt *FailoverOptions) *ClusterClient

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

func (*ClusterClient) AddHook Uses

func (hs *ClusterClient) AddHook(hook Hook)

func (ClusterClient) Append Uses

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

func (ClusterClient) BLPop Uses

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

func (ClusterClient) BRPop Uses

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

func (ClusterClient) BRPopLPush Uses

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

func (ClusterClient) BZPopMax Uses

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

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

func (ClusterClient) BZPopMin Uses

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

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

func (ClusterClient) BgRewriteAOF Uses

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

func (ClusterClient) BgSave Uses

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

func (ClusterClient) BitCount Uses

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

func (ClusterClient) BitField Uses

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

func (ClusterClient) BitOpAnd Uses

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

func (ClusterClient) BitOpNot Uses

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

func (ClusterClient) BitOpOr Uses

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

func (ClusterClient) BitOpXor Uses

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

func (ClusterClient) BitPos Uses

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

func (ClusterClient) ClientGetName Uses

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

ClientGetName returns the name of the connection.

func (ClusterClient) ClientID Uses

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

func (ClusterClient) ClientKill Uses

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

func (ClusterClient) ClientKillByFilter Uses

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 Uses

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

func (ClusterClient) ClientPause Uses

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

func (ClusterClient) ClientUnblock Uses

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

func (ClusterClient) ClientUnblockWithError Uses

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

func (*ClusterClient) Close Uses

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 Uses

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

func (ClusterClient) ClusterAddSlotsRange Uses

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

func (ClusterClient) ClusterCountFailureReports Uses

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

func (ClusterClient) ClusterCountKeysInSlot Uses

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

func (ClusterClient) ClusterDelSlots Uses

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

func (ClusterClient) ClusterDelSlotsRange Uses

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

func (ClusterClient) ClusterFailover Uses

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

func (ClusterClient) ClusterForget Uses

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

func (ClusterClient) ClusterGetKeysInSlot Uses

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

func (ClusterClient) ClusterInfo Uses

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

func (ClusterClient) ClusterKeySlot Uses

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

func (ClusterClient) ClusterMeet Uses

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

func (ClusterClient) ClusterNodes Uses

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

func (ClusterClient) ClusterReplicate Uses

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

func (ClusterClient) ClusterResetHard Uses

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

func (ClusterClient) ClusterResetSoft Uses

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

func (ClusterClient) ClusterSaveConfig Uses

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

func (ClusterClient) ClusterSlaves Uses

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

func (ClusterClient) ClusterSlots Uses

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

func (ClusterClient) Command Uses

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

func (ClusterClient) ConfigGet Uses

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

func (ClusterClient) ConfigResetStat Uses

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

func (ClusterClient) ConfigRewrite Uses

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

func (ClusterClient) ConfigSet Uses

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

func (*ClusterClient) Context Uses

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

func (*ClusterClient) DBSize Uses

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

func (ClusterClient) DebugObject Uses

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

func (ClusterClient) Decr Uses

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

func (ClusterClient) DecrBy Uses

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

func (ClusterClient) Del Uses

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

func (*ClusterClient) Do Uses

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

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

func (ClusterClient) Dump Uses

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

func (ClusterClient) Echo Uses

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

func (ClusterClient) Eval Uses

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

func (ClusterClient) EvalSha Uses

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

func (ClusterClient) Exists Uses

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

func (ClusterClient) Expire Uses

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

func (ClusterClient) ExpireAt Uses

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

func (ClusterClient) FlushAll Uses

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

func (ClusterClient) FlushAllAsync Uses

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

func (ClusterClient) FlushDB Uses

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

func (ClusterClient) FlushDBAsync Uses

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

func (*ClusterClient) ForEachMaster Uses

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 Uses

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 Uses

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 Uses

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

func (ClusterClient) GeoDist Uses

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

func (ClusterClient) GeoHash Uses

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

func (ClusterClient) GeoPos Uses

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

func (ClusterClient) GeoRadius Uses

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 Uses

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

GeoRadius is a read-only GEORADIUSBYMEMBER_RO command.

func (ClusterClient) GeoRadiusByMemberStore Uses

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

GeoRadiusByMemberStore is a writing GEORADIUSBYMEMBER command.

func (ClusterClient) GeoRadiusStore Uses

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

GeoRadiusStore is a writing GEORADIUS command.

func (ClusterClient) Get Uses

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 Uses

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

func (ClusterClient) GetRange Uses

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

func (ClusterClient) GetSet Uses

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

func (ClusterClient) HDel Uses

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

func (ClusterClient) HExists Uses

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

func (ClusterClient) HGet Uses

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

func (ClusterClient) HGetAll Uses

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

func (ClusterClient) HIncrBy Uses

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

func (ClusterClient) HIncrByFloat Uses

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

func (ClusterClient) HKeys Uses

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

func (ClusterClient) HLen Uses

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

func (ClusterClient) HMGet Uses

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 Uses

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 Uses

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

func (ClusterClient) HSet Uses

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 Uses

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

func (ClusterClient) HVals Uses

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

func (ClusterClient) Incr Uses

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

func (ClusterClient) IncrBy Uses

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

func (ClusterClient) IncrByFloat Uses

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

func (ClusterClient) Info Uses

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

func (ClusterClient) Keys Uses

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

func (ClusterClient) LIndex Uses

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

func (ClusterClient) LInsert Uses

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

func (ClusterClient) LInsertAfter Uses

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

func (ClusterClient) LInsertBefore Uses

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

func (ClusterClient) LLen Uses

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

func (ClusterClient) LPop Uses

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

func (ClusterClient) LPos Uses

func (c ClusterClient) LPos(ctx context.Context, key string, value string, a LPosArgs) *IntCmd

func (ClusterClient) LPosCount Uses

func (c ClusterClient) LPosCount(ctx context.Context, key string, value string, count int64, a LPosArgs) *IntSliceCmd

func (ClusterClient) LPush Uses

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

func (ClusterClient) LPushX Uses

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

func (ClusterClient) LRange Uses

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

func (ClusterClient) LRem Uses

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

func (ClusterClient) LSet Uses

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

func (ClusterClient) LTrim Uses

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

func (ClusterClient) LastSave Uses

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

func (ClusterClient) MGet Uses

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

func (ClusterClient) MSet Uses

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 Uses

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 Uses

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

func (ClusterClient) Migrate Uses

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

func (ClusterClient) Move Uses

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

func (ClusterClient) ObjectEncoding Uses

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

func (ClusterClient) ObjectIdleTime Uses

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

func (ClusterClient) ObjectRefCount Uses

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

func (*ClusterClient) Options Uses

func (c *ClusterClient) Options() *ClusterOptions

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

func (ClusterClient) PExpire Uses

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

func (ClusterClient) PExpireAt Uses

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

func (ClusterClient) PFAdd Uses

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

func (ClusterClient) PFCount Uses

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

func (ClusterClient) PFMerge Uses

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

func (*ClusterClient) PSubscribe Uses

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 Uses

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

func (ClusterClient) Persist Uses

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

func (ClusterClient) Ping Uses

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

func (*ClusterClient) Pipeline Uses

func (c *ClusterClient) Pipeline() Pipeliner

func (*ClusterClient) Pipelined Uses

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

func (*ClusterClient) PoolStats Uses

func (c *ClusterClient) PoolStats() *PoolStats

PoolStats returns accumulated connection pool stats.

func (*ClusterClient) Process Uses

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

func (ClusterClient) PubSubChannels Uses

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

func (ClusterClient) PubSubNumPat Uses

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

func (ClusterClient) PubSubNumSub Uses

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

func (ClusterClient) Publish Uses

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

Publish posts the message to the channel.

func (ClusterClient) Quit Uses

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

func (ClusterClient) RPop Uses

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

func (ClusterClient) RPopLPush Uses

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

func (ClusterClient) RPush Uses

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

func (ClusterClient) RPushX Uses

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

func (ClusterClient) RandomKey Uses

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

func (ClusterClient) ReadOnly Uses

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

func (ClusterClient) ReadWrite Uses

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

func (*ClusterClient) ReloadState Uses

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 Uses

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

func (ClusterClient) RenameNX Uses

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

func (ClusterClient) Restore Uses

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

func (ClusterClient) RestoreReplace Uses

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

func (ClusterClient) SAdd Uses

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

func (ClusterClient) SCard Uses

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

func (ClusterClient) SDiff Uses

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

func (ClusterClient) SDiffStore Uses

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

func (ClusterClient) SInter Uses

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

func (ClusterClient) SInterStore Uses

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

func (ClusterClient) SIsMember Uses

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

func (ClusterClient) SMembers Uses

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

Redis `SMEMBERS key` command output as a slice.

func (ClusterClient) SMembersMap Uses

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

Redis `SMEMBERS key` command output as a map.

func (ClusterClient) SMove Uses

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

func (ClusterClient) SPop Uses

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

Redis `SPOP key` command.

func (ClusterClient) SPopN Uses

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

Redis `SPOP key count` command.

func (ClusterClient) SRandMember Uses

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

Redis `SRANDMEMBER key` command.

func (ClusterClient) SRandMemberN Uses

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

Redis `SRANDMEMBER key count` command.

func (ClusterClient) SRem Uses

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

func (ClusterClient) SScan Uses

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

func (ClusterClient) SUnion Uses

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

func (ClusterClient) SUnionStore Uses

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

func (ClusterClient) Save Uses

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

func (ClusterClient) Scan Uses

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

func (ClusterClient) ScriptExists Uses

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

func (ClusterClient) ScriptFlush Uses

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

func (ClusterClient) ScriptKill Uses

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

func (ClusterClient) ScriptLoad Uses

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

func (ClusterClient) Set Uses

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 Uses

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

func (ClusterClient) SetEX Uses

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

Redis `SETEX key expiration value` command.

func (ClusterClient) SetNX Uses

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 Uses

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

func (ClusterClient) SetXX Uses

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 Uses

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

func (ClusterClient) ShutdownNoSave Uses

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

func (ClusterClient) ShutdownSave Uses

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

func (ClusterClient) SlaveOf Uses

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

func (ClusterClient) SlowLogGet Uses

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

func (ClusterClient) Sort Uses

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

func (ClusterClient) SortInterfaces Uses

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

func (ClusterClient) SortStore Uses

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

func (ClusterClient) StrLen Uses

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

func (*ClusterClient) Subscribe Uses

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 Uses

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

func (ClusterClient) TTL Uses

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

func (ClusterClient) Time Uses

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

func (ClusterClient) Touch Uses

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

func (*ClusterClient) TxPipeline Uses

func (c *ClusterClient) TxPipeline() Pipeliner

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

func (*ClusterClient) TxPipelined Uses

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

func (ClusterClient) Type Uses

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

func (ClusterClient) Wait Uses

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

func (*ClusterClient) Watch Uses

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

func (*ClusterClient) WithContext Uses

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

func (ClusterClient) XAck Uses

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

func (ClusterClient) XAdd Uses

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

func (ClusterClient) XClaim Uses

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

func (ClusterClient) XClaimJustID Uses

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

func (ClusterClient) XDel Uses

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

func (ClusterClient) XGroupCreate Uses

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

func (ClusterClient) XGroupCreateMkStream Uses

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

func (ClusterClient) XGroupDelConsumer Uses

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

func (ClusterClient) XGroupDestroy Uses

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

func (ClusterClient) XGroupSetID Uses

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

func (ClusterClient) XInfoGroups Uses

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

func (ClusterClient) XInfoStream Uses

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

func (ClusterClient) XLen Uses

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

func (ClusterClient) XPending Uses

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

func (ClusterClient) XPendingExt Uses

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

func (ClusterClient) XRange Uses

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

func (ClusterClient) XRangeN Uses

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

func (ClusterClient) XRead Uses

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

func (ClusterClient) XReadGroup Uses

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

func (ClusterClient) XReadStreams Uses

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

func (ClusterClient) XRevRange Uses

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

func (ClusterClient) XRevRangeN Uses

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

func (ClusterClient) XTrim Uses

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

func (ClusterClient) XTrimApprox Uses

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

func (ClusterClient) ZAdd Uses

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

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

func (ClusterClient) ZAddCh Uses

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

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

func (ClusterClient) ZAddNX Uses

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

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

func (ClusterClient) ZAddNXCh Uses

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 Uses

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

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

func (ClusterClient) ZAddXXCh Uses

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 Uses

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

func (ClusterClient) ZCount Uses

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

func (ClusterClient) ZIncr Uses

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

Redis `ZADD key INCR score member` command.

func (ClusterClient) ZIncrBy Uses

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

func (ClusterClient) ZIncrNX Uses

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

Redis `ZADD key NX INCR score member` command.

func (ClusterClient) ZIncrXX Uses

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

Redis `ZADD key XX INCR score member` command.

func (ClusterClient) ZInterStore Uses

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

func (ClusterClient) ZLexCount Uses

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

func (ClusterClient) ZPopMax Uses

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

func (ClusterClient) ZPopMin Uses

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

func (ClusterClient) ZRange Uses

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

func (ClusterClient) ZRangeByLex Uses

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

func (ClusterClient) ZRangeByScore Uses

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

func (ClusterClient) ZRangeByScoreWithScores Uses

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

func (ClusterClient) ZRangeWithScores Uses

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

func (ClusterClient) ZRank Uses

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

func (ClusterClient) ZRem Uses

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

func (ClusterClient) ZRemRangeByLex Uses

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

func (ClusterClient) ZRemRangeByRank Uses

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

func (ClusterClient) ZRemRangeByScore Uses

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

func (ClusterClient) ZRevRange Uses

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

func (ClusterClient) ZRevRangeByLex Uses

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

func (ClusterClient) ZRevRangeByScore Uses

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

func (ClusterClient) ZRevRangeByScoreWithScores Uses

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

func (ClusterClient) ZRevRangeWithScores Uses

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

func (ClusterClient) ZRevRank Uses

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

func (ClusterClient) ZScan Uses

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

func (ClusterClient) ZScore Uses

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

func (ClusterClient) ZUnionStore Uses

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

type ClusterNode Uses

type ClusterNode struct {
    ID   string
    Addr string
}

type ClusterOptions Uses

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

    // NewClient creates a cluster node client with provided name and options.
    NewClient func(opt *Options) *Client

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

    // Enables read-only commands on slave nodes.
    ReadOnly bool
    // Allows routing read-only commands to the closest master or slave node.
    // It automatically enables ReadOnly.
    RouteByLatency bool
    // Allows routing read-only commands to the random master or slave node.
    // It automatically enables ReadOnly.
    RouteRandomly bool

    // Optional function that returns cluster slots information.
    // It is useful to manually create cluster of standalone Redis servers
    // and load-balance read/write operations between master and slaves.
    // It can use service like ZooKeeper to maintain configuration information
    // and Cluster.ReloadState to manually trigger state reloading.
    ClusterSlots func(context.Context) ([]ClusterSlot, error)

    Dialer func(ctx context.Context, network, addr string) (net.Conn, error)

    OnConnect func(ctx context.Context, cn *Conn) error

    Username string
    Password string

    MaxRetries      int
    MinRetryBackoff time.Duration
    MaxRetryBackoff time.Duration

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

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

    TLSConfig *tls.Config
}

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

type ClusterSlot Uses

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

type ClusterSlotsCmd Uses

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

func NewClusterSlotsCmd Uses

func NewClusterSlotsCmd(ctx context.Context, args ...interface{}) *ClusterSlotsCmd

func NewClusterSlotsCmdResult Uses

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

NewClusterSlotsCmdResult returns a ClusterSlotsCmd initialised with val and err for testing.

func (*ClusterSlotsCmd) Args Uses

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

func (*ClusterSlotsCmd) Err Uses

func (cmd *ClusterSlotsCmd) Err() error

func (*ClusterSlotsCmd) FullName Uses

func (cmd *ClusterSlotsCmd) FullName() string

func (*ClusterSlotsCmd) Name Uses

func (cmd *ClusterSlotsCmd) Name() string

func (*ClusterSlotsCmd) Result Uses

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

func (*ClusterSlotsCmd) SetErr Uses

func (cmd *ClusterSlotsCmd) SetErr(e error)

func (*ClusterSlotsCmd) String Uses

func (cmd *ClusterSlotsCmd) String() string

func (*ClusterSlotsCmd) Val Uses

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

type Cmd Uses

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

func NewCmd Uses

func NewCmd(ctx context.Context, args ...interface{}) *Cmd

func NewCmdResult Uses

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

NewCmdResult returns a Cmd initialised with val and err for testing.

func (*Cmd) Args Uses

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

func (*Cmd) Bool Uses

func (cmd *Cmd) Bool() (bool, error)

func (*Cmd) Err Uses

func (cmd *Cmd) Err() error

func (*Cmd) Float32 Uses

func (cmd *Cmd) Float32() (float32, error)

func (*Cmd) Float64 Uses

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

func (*Cmd) FullName Uses

func (cmd *Cmd) FullName() string

func (*Cmd) Int Uses

func (cmd *Cmd) Int() (int, error)

func (*Cmd) Int64 Uses

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

func (*Cmd) Name Uses

func (cmd *Cmd) Name() string

func (*Cmd) Result Uses

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

func (*Cmd) SetErr Uses

func (cmd *Cmd) SetErr(e error)

func (*Cmd) String Uses

func (cmd *Cmd) String() string

func (*Cmd) Text Uses

func (cmd *Cmd) Text() (string, error)

func (*Cmd) Uint64 Uses

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

func (*Cmd) Val Uses

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

type Cmdable Uses

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

    TxPipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)
    TxPipeline() Pipeliner

    Command(ctx context.Context) *CommandsInfoCmd
    ClientGetName(ctx context.Context) *StringCmd
    Echo(ctx context.Context, message interface{}) *StringCmd
    Ping(ctx context.Context) *StatusCmd
    Quit(ctx context.Context) *StatusCmd
    Del(ctx context.Context, keys ...string) *IntCmd
    Unlink(ctx context.Context, keys ...string) *IntCmd
    Dump(ctx context.Context, key string) *StringCmd
    Exists(ctx context.Context, keys ...string) *IntCmd
    Expire(ctx context.Context, key string, expiration time.Duration) *BoolCmd
    ExpireAt(ctx context.Context, key string, tm time.Time) *BoolCmd
    Keys(ctx context.Context, pattern string) *StringSliceCmd
    Migrate(ctx context.Context, host, port, key string, db int, timeout time.Duration) *StatusCmd
    Move(ctx context.Context, key string, db int) *BoolCmd
    ObjectRefCount(ctx context.Context, key string) *IntCmd
    ObjectEncoding(ctx context.Context, key string) *StringCmd
    ObjectIdleTime(ctx context.Context, key string) *DurationCmd
    Persist(ctx context.Context, key string) *BoolCmd
    PExpire(ctx context.Context, key string, expiration time.Duration) *BoolCmd
    PExpireAt(ctx context.Context, key string, tm time.Time) *BoolCmd
    PTTL(ctx context.Context, key string) *DurationCmd
    RandomKey(ctx context.Context) *StringCmd
    Rename(ctx context.Context, key, newkey string) *StatusCmd
    RenameNX(ctx context.Context, key, newkey string) *BoolCmd
    Restore(ctx context.Context, key string, ttl time.Duration, value string) *StatusCmd
    RestoreReplace(ctx context.Context, key string, ttl time.Duration, value string) *StatusCmd
    Sort(ctx context.Context, key string, sort *Sort) *StringSliceCmd
    SortStore(ctx context.Context, key, store string, sort *Sort) *IntCmd
    SortInterfaces(ctx context.Context, key string, sort *Sort) *SliceCmd
    Touch(ctx context.Context, keys ...string) *IntCmd
    TTL(ctx context.Context, key string) *DurationCmd
    Type(ctx context.Context, key string) *StatusCmd
    Append(ctx context.Context, key, value string) *IntCmd
    Decr(ctx context.Context, key string) *IntCmd
    DecrBy(ctx context.Context, key string, decrement int64) *IntCmd
    Get(ctx context.Context, key string) *StringCmd
    GetRange(ctx context.Context, key string, start, end int64) *StringCmd
    GetSet(ctx context.Context, key string, value interface{}) *StringCmd
    Incr(ctx context.Context, key string) *IntCmd
    IncrBy(ctx context.Context, key string, value int64) *IntCmd
    IncrByFloat(ctx context.Context, key string, value float64) *FloatCmd
    MGet(ctx context.Context, keys ...string) *SliceCmd
    MSet(ctx context.Context, values ...interface{}) *StatusCmd
    MSetNX(ctx context.Context, values ...interface{}) *BoolCmd
    Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd
    SetEX(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd
    SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd
    SetXX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd
    SetRange(ctx context.Context, key string, offset int64, value string) *IntCmd
    StrLen(ctx context.Context, key string) *IntCmd

    GetBit(ctx context.Context, key string, offset int64) *IntCmd
    SetBit(ctx context.Context, key string, offset int64, value int) *IntCmd
    BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd
    BitOpAnd(ctx context.Context, destKey string, keys ...string) *IntCmd
    BitOpOr(ctx context.Context, destKey string, keys ...string) *IntCmd
    BitOpXor(ctx context.Context, destKey string, keys ...string) *IntCmd
    BitOpNot(ctx context.Context, destKey string, key string) *IntCmd
    BitPos(ctx context.Context, key string, bit int64, pos ...int64) *IntCmd
    BitField(ctx context.Context, key string, args ...interface{}) *IntSliceCmd

    Scan(ctx context.Context, cursor uint64, match string, count int64) *ScanCmd
    SScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd
    HScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd
    ZScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd

    HDel(ctx context.Context, key string, fields ...string) *IntCmd
    HExists(ctx context.Context, key, field string) *BoolCmd
    HGet(ctx context.Context, key, field string) *StringCmd
    HGetAll(ctx context.Context, key string) *StringStringMapCmd
    HIncrBy(ctx context.Context, key, field string, incr int64) *IntCmd
    HIncrByFloat(ctx context.Context, key, field string, incr float64) *FloatCmd
    HKeys(ctx context.Context, key string) *StringSliceCmd
    HLen(ctx context.Context, key string) *IntCmd
    HMGet(ctx context.Context, key string, fields ...string) *SliceCmd
    HSet(ctx context.Context, key string, values ...interface{}) *IntCmd
    HMSet(ctx context.Context, key string, values ...interface{}) *BoolCmd
    HSetNX(ctx context.Context, key, field string, value interface{}) *BoolCmd
    HVals(ctx context.Context, key string) *StringSliceCmd

    BLPop(ctx context.Context, timeout time.Duration, keys ...string) *StringSliceCmd
    BRPop(ctx context.Context, timeout time.Duration, keys ...string) *StringSliceCmd
    BRPopLPush(ctx context.Context, source, destination string, timeout time.Duration) *StringCmd
    LIndex(ctx context.Context, key string, index int64) *StringCmd
    LInsert(ctx context.Context, key, op string, pivot, value interface{}) *IntCmd
    LInsertBefore(ctx context.Context, key string, pivot, value interface{}) *IntCmd
    LInsertAfter(ctx context.Context, key string, pivot, value interface{}) *IntCmd
    LLen(ctx context.Context, key string) *IntCmd
    LPop(ctx context.Context, key string) *StringCmd
    LPos(ctx context.Context, key string, value string, args LPosArgs) *IntCmd
    LPosCount(ctx context.Context, key string, value string, count int64, args LPosArgs) *IntSliceCmd
    LPush(ctx context.Context, key string, values ...interface{}) *IntCmd
    LPushX(ctx context.Context, key string, values ...interface{}) *IntCmd
    LRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd
    LRem(ctx context.Context, key string, count int64, value interface{}) *IntCmd
    LSet(ctx context.Context, key string, index int64, value interface{}) *StatusCmd
    LTrim(ctx context.Context, key string, start, stop int64) *StatusCmd
    RPop(ctx context.Context, key string) *StringCmd
    RPopLPush(ctx context.Context, source, destination string) *StringCmd
    RPush(ctx context.Context, key string, values ...interface{}) *IntCmd
    RPushX(ctx context.Context, key string, values ...interface{}) *IntCmd

    SAdd(ctx context.Context, key string, members ...interface{}) *IntCmd
    SCard(ctx context.Context, key string) *IntCmd
    SDiff(ctx context.Context, keys ...string) *StringSliceCmd
    SDiffStore(ctx context.Context, destination string, keys ...string) *IntCmd
    SInter(ctx context.Context, keys ...string) *StringSliceCmd
    SInterStore(ctx context.Context, destination string, keys ...string) *IntCmd
    SIsMember(ctx context.Context, key string, member interface{}) *BoolCmd
    SMembers(ctx context.Context, key string) *StringSliceCmd
    SMembersMap(ctx context.Context, key string) *StringStructMapCmd
    SMove(ctx context.Context, source, destination string, member interface{}) *BoolCmd
    SPop(ctx context.Context, key string) *StringCmd
    SPopN(ctx context.Context, key string, count int64) *StringSliceCmd
    SRandMember(ctx context.Context, key string) *StringCmd
    SRandMemberN(ctx context.Context, key string, count int64) *StringSliceCmd
    SRem(ctx context.Context, key string, members ...interface{}) *IntCmd
    SUnion(ctx context.Context, keys ...string) *StringSliceCmd
    SUnionStore(ctx context.Context, destination string, keys ...string) *IntCmd

    XAdd(ctx context.Context, a *XAddArgs) *StringCmd
    XDel(ctx context.Context, stream string, ids ...string) *IntCmd
    XLen(ctx context.Context, stream string) *IntCmd
    XRange(ctx context.Context, stream, start, stop string) *XMessageSliceCmd
    XRangeN(ctx context.Context, stream, start, stop string, count int64) *XMessageSliceCmd
    XRevRange(ctx context.Context, stream string, start, stop string) *XMessageSliceCmd
    XRevRangeN(ctx context.Context, stream string, start, stop string, count int64) *XMessageSliceCmd
    XRead(ctx context.Context, a *XReadArgs) *XStreamSliceCmd
    XReadStreams(ctx context.Context, streams ...string) *XStreamSliceCmd
    XGroupCreate(ctx context.Context, stream, group, start string) *StatusCmd
    XGroupCreateMkStream(ctx context.Context, stream, group, start string) *StatusCmd
    XGroupSetID(ctx context.Context, stream, group, start string) *StatusCmd
    XGroupDestroy(ctx context.Context, stream, group string) *IntCmd
    XGroupDelConsumer(ctx context.Context, stream, group, consumer string) *IntCmd
    XReadGroup(ctx context.Context, a *XReadGroupArgs) *XStreamSliceCmd
    XAck(ctx context.Context, stream, group string, ids ...string) *IntCmd
    XPending(ctx context.Context, stream, group string) *XPendingCmd
    XPendingExt(ctx context.Context, a *XPendingExtArgs) *XPendingExtCmd
    XClaim(ctx context.Context, a *XClaimArgs) *XMessageSliceCmd
    XClaimJustID(ctx context.Context, a *XClaimArgs) *StringSliceCmd
    XTrim(ctx context.Context, key string, maxLen int64) *IntCmd
    XTrimApprox(ctx context.Context, key string, maxLen int64) *IntCmd
    XInfoGroups(ctx context.Context, key string) *XInfoGroupsCmd
    XInfoStream(ctx context.Context, key string) *XInfoStreamCmd

    BZPopMax(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd
    BZPopMin(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd
    ZAdd(ctx context.Context, key string, members ...*Z) *IntCmd
    ZAddNX(ctx context.Context, key string, members ...*Z) *IntCmd
    ZAddXX(ctx context.Context, key string, members ...*Z) *IntCmd
    ZAddCh(ctx context.Context, key string, members ...*Z) *IntCmd
    ZAddNXCh(ctx context.Context, key string, members ...*Z) *IntCmd
    ZAddXXCh(ctx context.Context, key string, members ...*Z) *IntCmd
    ZIncr(ctx context.Context, key string, member *Z) *FloatCmd
    ZIncrNX(ctx context.Context, key string, member *Z) *FloatCmd
    ZIncrXX(ctx context.Context, key string, member *Z) *FloatCmd
    ZCard(ctx context.Context, key string) *IntCmd
    ZCount(ctx context.Context, key, min, max string) *IntCmd
    ZLexCount(ctx context.Context, key, min, max string) *IntCmd
    ZIncrBy(ctx context.Context, key string, increment float64, member string) *FloatCmd
    ZInterStore(ctx context.Context, destination string, store *ZStore) *IntCmd
    ZPopMax(ctx context.Context, key string, count ...int64) *ZSliceCmd
    ZPopMin(ctx context.Context, key string, count ...int64) *ZSliceCmd
    ZRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd
    ZRangeWithScores(ctx context.Context, key string, start, stop int64) *ZSliceCmd
    ZRangeByScore(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd
    ZRangeByLex(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd
    ZRangeByScoreWithScores(ctx context.Context, key string, opt *ZRangeBy) *ZSliceCmd
    ZRank(ctx context.Context, key, member string) *IntCmd
    ZRem(ctx context.Context, key string, members ...interface{}) *IntCmd
    ZRemRangeByRank(ctx context.Context, key string, start, stop int64) *IntCmd
    ZRemRangeByScore(ctx context.Context, key, min, max string) *IntCmd
    ZRemRangeByLex(ctx context.Context, key, min, max string) *IntCmd
    ZRevRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd
    ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) *ZSliceCmd
    ZRevRangeByScore(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd
    ZRevRangeByLex(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd
    ZRevRangeByScoreWithScores(ctx context.Context, key string, opt *ZRangeBy) *ZSliceCmd
    ZRevRank(ctx context.Context, key, member string) *IntCmd
    ZScore(ctx context.Context, key, member string) *FloatCmd
    ZUnionStore(ctx context.Context, dest string, store *ZStore) *IntCmd

    PFAdd(ctx context.Context, key string, els ...interface{}) *IntCmd
    PFCount(ctx context.Context, keys ...string) *IntCmd
    PFMerge(ctx context.Context, dest string, keys ...string) *StatusCmd

    BgRewriteAOF(ctx context.Context) *StatusCmd
    BgSave(ctx context.Context) *StatusCmd
    ClientKill(ctx context.Context, ipPort string) *StatusCmd
    ClientKillByFilter(ctx context.Context, keys ...string) *IntCmd
    ClientList(ctx context.Context) *StringCmd
    ClientPause(ctx context.Context, dur time.Duration) *BoolCmd
    ClientID(ctx context.Context) *IntCmd
    ConfigGet(ctx context.Context, parameter string) *SliceCmd
    ConfigResetStat(ctx context.Context) *StatusCmd
    ConfigSet(ctx context.Context, parameter, value string) *StatusCmd
    ConfigRewrite(ctx context.Context) *StatusCmd
    DBSize(ctx context.Context) *IntCmd
    FlushAll(ctx context.Context) *StatusCmd
    FlushAllAsync(ctx context.Context) *StatusCmd
    FlushDB(ctx context.Context) *StatusCmd
    FlushDBAsync(ctx context.Context) *StatusCmd
    Info(ctx context.Context, section ...string) *StringCmd
    LastSave(ctx context.Context) *IntCmd
    Save(ctx context.Context) *StatusCmd
    Shutdown(ctx context.Context) *StatusCmd
    ShutdownSave(ctx context.Context) *StatusCmd
    ShutdownNoSave(ctx context.Context) *StatusCmd
    SlaveOf(ctx context.Context, host, port string) *StatusCmd
    Time(ctx context.Context) *TimeCmd
    DebugObject(ctx context.Context, key string) *StringCmd
    ReadOnly(ctx context.Context) *StatusCmd
    ReadWrite(ctx context.Context) *StatusCmd
    MemoryUsage(ctx context.Context, key string, samples ...int) *IntCmd

    Eval(ctx context.Context, script string, keys []string, args ...interface{}) *Cmd
    EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *Cmd
    ScriptExists(ctx context.Context, hashes ...string) *BoolSliceCmd
    ScriptFlush(ctx context.Context) *StatusCmd
    ScriptKill(ctx context.Context) *StatusCmd
    ScriptLoad(ctx context.Context, script string) *StringCmd

    Publish(ctx context.Context, channel string, message interface{}) *IntCmd
    PubSubChannels(ctx context.Context, pattern string) *StringSliceCmd
    PubSubNumSub(ctx context.Context, channels ...string) *StringIntMapCmd
    PubSubNumPat(ctx context.Context) *IntCmd

    ClusterSlots(ctx context.Context) *ClusterSlotsCmd
    ClusterNodes(ctx context.Context) *StringCmd
    ClusterMeet(ctx context.Context, host, port string) *StatusCmd
    ClusterForget(ctx context.Context, nodeID string) *StatusCmd
    ClusterReplicate(ctx context.Context, nodeID string) *StatusCmd
    ClusterResetSoft(ctx context.Context) *StatusCmd
    ClusterResetHard(ctx context.Context) *StatusCmd
    ClusterInfo(ctx context.Context) *StringCmd
    ClusterKeySlot(ctx context.Context, key string) *IntCmd
    ClusterGetKeysInSlot(ctx context.Context, slot int, count int) *StringSliceCmd
    ClusterCountFailureReports(ctx context.Context, nodeID string) *IntCmd
    ClusterCountKeysInSlot(ctx context.Context, slot int) *IntCmd
    ClusterDelSlots(ctx context.Context, slots ...int) *StatusCmd
    ClusterDelSlotsRange(ctx context.Context, min, max int) *StatusCmd
    ClusterSaveConfig(ctx context.Context) *StatusCmd
    ClusterSlaves(ctx context.Context, nodeID string) *StringSliceCmd
    ClusterFailover(ctx context.Context) *StatusCmd
    ClusterAddSlots(ctx context.Context, slots ...int) *StatusCmd
    ClusterAddSlotsRange(ctx context.Context, min, max int) *StatusCmd

    GeoAdd(ctx context.Context, key string, geoLocation ...*GeoLocation) *IntCmd
    GeoPos(ctx context.Context, key string, members ...string) *GeoPosCmd
    GeoRadius(ctx context.Context, key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd
    GeoRadiusStore(ctx context.Context, key string, longitude, latitude float64, query *GeoRadiusQuery) *IntCmd
    GeoRadiusByMember(ctx context.Context, key, member string, query *GeoRadiusQuery) *GeoLocationCmd
    GeoRadiusByMemberStore(ctx context.Context, key, member string, query *GeoRadiusQuery) *IntCmd
    GeoDist(ctx context.Context, key string, member1, member2, unit string) *FloatCmd
    GeoHash(ctx context.Context, key string, members ...string) *StringSliceCmd
}

type Cmder Uses

type Cmder interface {
    Name() string
    FullName() string
    Args() []interface{}
    String() string

    SetErr(error)
    Err() error
    // contains filtered or unexported methods
}

type CommandInfo Uses

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

type CommandsInfoCmd Uses

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

func NewCommandsInfoCmd Uses

func NewCommandsInfoCmd(ctx context.Context, args ...interface{}) *CommandsInfoCmd

func NewCommandsInfoCmdResult Uses

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

NewCommandsInfoCmdResult returns a CommandsInfoCmd initialised with val and err for testing.

func (*CommandsInfoCmd) Args Uses

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

func (*CommandsInfoCmd) Err Uses

func (cmd *CommandsInfoCmd) Err() error

func (*CommandsInfoCmd) FullName Uses

func (cmd *CommandsInfoCmd) FullName() string

func (*CommandsInfoCmd) Name Uses

func (cmd *CommandsInfoCmd) Name() string

func (*CommandsInfoCmd) Result Uses

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

func (*CommandsInfoCmd) SetErr Uses

func (cmd *CommandsInfoCmd) SetErr(e error)

func (*CommandsInfoCmd) String Uses

func (cmd *CommandsInfoCmd) String() string

func (*CommandsInfoCmd) Val Uses

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

type Conn Uses

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

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

Code:

conn := rdb.Conn(context.Background())

err := conn.ClientSetName(ctx, "foobar").Err()
if err != nil {
    panic(err)
}

// Open other connections.
for i := 0; i < 10; i++ {
    go rdb.Ping(ctx)
}

s, err := conn.ClientGetName(ctx).Result()
if err != nil {
    panic(err)
}
fmt.Println(s)

Output:

foobar

func (*Conn) Pipeline Uses

func (c *Conn) Pipeline() Pipeliner

func (*Conn) Pipelined Uses

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

func (*Conn) Process Uses

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

func (*Conn) TxPipeline Uses

func (c *Conn) TxPipeline() Pipeliner

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

func (*Conn) TxPipelined Uses

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

type ConsistentHash Uses

type ConsistentHash interface {
    Get(string) string
}

type DurationCmd Uses

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

func NewDurationCmd Uses

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

func NewDurationResult Uses

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

NewDurationResult returns a DurationCmd initialised with val and err for testing.

func (*DurationCmd) Args Uses

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

func (*DurationCmd) Err Uses

func (cmd *DurationCmd) Err() error

func (*DurationCmd) FullName Uses

func (cmd *DurationCmd) FullName() string

func (*DurationCmd) Name Uses

func (cmd *DurationCmd) Name() string

func (*DurationCmd) Result Uses

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

func (*DurationCmd) SetErr Uses

func (cmd *DurationCmd) SetErr(e error)

func (*DurationCmd) String Uses

func (cmd *DurationCmd) String() string

func (*DurationCmd) Val Uses

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

type Error Uses

type Error interface {
    error

    // RedisError is a no-op function but
    // serves to distinguish types that are Redis
    // errors from ordinary errors: a type is a
    // Redis error if it has a RedisError method.
    RedisError()
}

type FailoverOptions Uses

type FailoverOptions struct {
    // The master name.
    MasterName string
    // A seed list of host:port addresses of sentinel nodes.
    SentinelAddrs []string
    // Sentinel password from "requirepass <password>" (if enabled) in Sentinel configuration
    SentinelPassword string

    // Allows routing read-only commands to the closest master or slave node.
    // This option only works with NewFailoverClusterClient.
    RouteByLatency bool
    // Allows routing read-only commands to the random master or slave node.
    // This option only works with NewFailoverClusterClient.
    RouteRandomly bool

    // Route all commands to slave read-only nodes.
    SlaveOnly bool

    Dialer    func(ctx context.Context, network, addr string) (net.Conn, error)
    OnConnect func(ctx context.Context, cn *Conn) error

    Username string
    Password string
    DB       int

    MaxRetries      int
    MinRetryBackoff time.Duration
    MaxRetryBackoff time.Duration

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

    PoolSize           int
    MinIdleConns       int
    MaxConnAge         time.Duration
    PoolTimeout        time.Duration
    IdleTimeout        time.Duration
    IdleCheckFrequency time.Duration

    TLSConfig *tls.Config
}

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

type FloatCmd Uses

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

func NewFloatCmd Uses

func NewFloatCmd(ctx context.Context, args ...interface{}) *FloatCmd

func NewFloatResult Uses

func NewFloatResult(val float64, err error) *FloatCmd

NewFloatResult returns a FloatCmd initialised with val and err for testing.

func (*FloatCmd) Args Uses

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

func (*FloatCmd) Err Uses

func (cmd *FloatCmd) Err() error

func (*FloatCmd) FullName Uses

func (cmd *FloatCmd) FullName() string

func (*FloatCmd) Name Uses

func (cmd *FloatCmd) Name() string

func (*FloatCmd) Result Uses

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

func (*FloatCmd) SetErr Uses

func (cmd *FloatCmd) SetErr(e error)

func (*FloatCmd) String Uses

func (cmd *FloatCmd) String() string

func (*FloatCmd) Val Uses

func (cmd *FloatCmd) Val() float64

type GeoLocation Uses

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

GeoLocation is used with GeoAdd to add geospatial location.

type GeoLocationCmd Uses

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

func NewGeoLocationCmd Uses

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

func NewGeoLocationCmdResult Uses

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

NewGeoLocationCmdResult returns a GeoLocationCmd initialised with val and err for testing.

func (*GeoLocationCmd) Args Uses

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

func (*GeoLocationCmd) Err Uses

func (cmd *GeoLocationCmd) Err() error

func (*GeoLocationCmd) FullName Uses

func (cmd *GeoLocationCmd) FullName() string

func (*GeoLocationCmd) Name Uses

func (cmd *GeoLocationCmd) Name() string

func (*GeoLocationCmd) Result Uses

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

func (*GeoLocationCmd) SetErr Uses

func (cmd *GeoLocationCmd) SetErr(e error)

func (*GeoLocationCmd) String Uses

func (cmd *GeoLocationCmd) String() string

func (*GeoLocationCmd) Val Uses

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

type GeoPos Uses

type GeoPos struct {
    Longitude, Latitude float64
}

type GeoPosCmd Uses

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

func NewGeoPosCmd Uses

func NewGeoPosCmd(ctx context.Context, args ...interface{}) *GeoPosCmd

func NewGeoPosCmdResult Uses

func NewGeoPosCmdResult(val []*GeoPos, err error) *GeoPosCmd

NewGeoPosCmdResult returns a GeoPosCmd initialised with val and err for testing.

func (*GeoPosCmd) Args Uses

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

func (*GeoPosCmd) Err Uses

func (cmd *GeoPosCmd) Err() error

func (*GeoPosCmd) FullName Uses

func (cmd *GeoPosCmd) FullName() string

func (*GeoPosCmd) Name Uses

func (cmd *GeoPosCmd) Name() string

func (*GeoPosCmd) Result Uses

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

func (*GeoPosCmd) SetErr Uses

func (cmd *GeoPosCmd) SetErr(e error)

func (*GeoPosCmd) String Uses

func (cmd *GeoPosCmd) String() string

func (*GeoPosCmd) Val Uses

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

type GeoRadiusQuery Uses

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
    Store     string
    StoreDist string
}

GeoRadiusQuery is used with GeoRadius to query geospatial index.

type Hook Uses

type Hook interface {
    BeforeProcess(ctx context.Context, cmd Cmder) (context.Context, error)
    AfterProcess(ctx context.Context, cmd Cmder) error

    BeforeProcessPipeline(ctx context.Context, cmds []Cmder) (context.Context, error)
    AfterProcessPipeline(ctx context.Context, cmds []Cmder) error
}

type IntCmd Uses

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

func NewIntCmd Uses

func NewIntCmd(ctx context.Context, args ...interface{}) *IntCmd

func NewIntResult Uses

func NewIntResult(val int64, err error) *IntCmd

NewIntResult returns an IntCmd initialised with val and err for testing.

func (*IntCmd) Args Uses

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

func (*IntCmd) Err Uses

func (cmd *IntCmd) Err() error

func (*IntCmd) FullName Uses

func (cmd *IntCmd) FullName() string

func (*IntCmd) Name Uses

func (cmd *IntCmd) Name() string

func (*IntCmd) Result Uses

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

func (*IntCmd) SetErr Uses

func (cmd *IntCmd) SetErr(e error)

func (*IntCmd) String Uses

func (cmd *IntCmd) String() string

func (*IntCmd) Uint64 Uses

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

func (*IntCmd) Val Uses

func (cmd *IntCmd) Val() int64

type IntSliceCmd Uses

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

func NewIntSliceCmd Uses

func NewIntSliceCmd(ctx context.Context, args ...interface{}) *IntSliceCmd

func (*IntSliceCmd) Args Uses

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

func (*IntSliceCmd) Err Uses

func (cmd *IntSliceCmd) Err() error

func (*IntSliceCmd) FullName Uses

func (cmd *IntSliceCmd) FullName() string

func (*IntSliceCmd) Name Uses

func (cmd *IntSliceCmd) Name() string

func (*IntSliceCmd) Result Uses

func (cmd *IntSliceCmd) Result() ([]int64, error)

func (*IntSliceCmd) SetErr Uses

func (cmd *IntSliceCmd) SetErr(e error)

func (*IntSliceCmd) String Uses

func (cmd *IntSliceCmd) String() string

func (*IntSliceCmd) Val Uses

func (cmd *IntSliceCmd) Val() []int64

type LPosArgs Uses

type LPosArgs struct {
    Rank, MaxLen int64
}

type Limiter Uses

type Limiter interface {
    // Allow returns nil if operation is allowed or an error otherwise.
    // If operation is allowed client must ReportResult of the operation
    // whether it is a success or a failure.
    Allow() error
    // ReportResult reports the result of the previously allowed operation.
    // nil indicates a success, non-nil error usually indicates a failure.
    ReportResult(result error)
}

Limiter is the interface of a rate limiter or a circuit breaker.

type Message Uses

type Message struct {
    Channel      string
    Pattern      string
    Payload      string
    PayloadSlice []string
}

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

func (*Message) String Uses

func (m *Message) String() string

type Options Uses

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(ctx context.Context, network, addr string) (net.Conn, error)

    // Hook that is called when new connection is established.
    OnConnect func(ctx context.Context, cn *Conn) error

    // Use the specified Username to authenticate the current connection
    // with one of the connections defined in the ACL list when connecting
    // to a Redis 6.0 instance, or greater, that is using the Redis ACL system.
    Username string
    // Optional password. Must match the password specified in the
    // requirepass server configuration option (if connecting to a Redis 5.0 instance, or lower),
    // or the User Password when connecting to a Redis 6.0 instance, or greater,
    // that is using the Redis ACL system.
    Password string

    // Database to be selected after connecting to the server.
    DB  int

    // Maximum number of retries before giving up.
    // Default is 3 retries.
    MaxRetries int
    // Minimum backoff between each retry.
    // Default is 8 milliseconds; -1 disables backoff.
    MinRetryBackoff time.Duration
    // Maximum backoff between each retry.
    // Default is 512 milliseconds; -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. Use value -1 for no timeout and 0 for default.
    // 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 per every CPU as reported by runtime.NumCPU.
    PoolSize int
    // Minimum number of idle connections which is useful when establishing
    // new connection is slow.
    MinIdleConns int
    // Connection age at which client retires (closes) the connection.
    // Default is to not close aged connections.
    MaxConnAge time.Duration
    // 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. -1 disables idle timeout check.
    IdleTimeout time.Duration
    // Frequency of idle checks made by idle connections reaper.
    // Default is 1 minute. -1 disables idle connections reaper,
    // but idle connections are still discarded by the client
    // if IdleTimeout is set.
    IdleCheckFrequency time.Duration

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

    // Limiter interface used to implemented circuit breaker or rate limiter.
    Limiter Limiter
    // contains filtered or unexported fields
}

Options keeps the settings to setup redis connection.

func ParseURL Uses

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

ParseURL parses an URL into Options that can be used to connect to Redis. Scheme is required. There are two connection types: by tcp socket and by unix socket. Tcp connection:

redis://<user>:<password>@<host>:<port>/<db_number>

Unix connection:

unix://<user>:<password>@</path/to/redis.sock>?db=<db_number>

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 Uses

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

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

Code:

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

rdb.Pipelined(ctx, func(pipe redis.Pipeliner) error {
    pipe.Ping(ctx)
    pipe.Ping(ctx)
    return nil
})

Output:

pipeline starting processing: [ping:  ping: ]
pipeline finished processing: [ping: PONG ping: PONG]

func (Pipeline) Append Uses

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

func (Pipeline) Auth Uses

func (c Pipeline) Auth(ctx context.Context, password string) *StatusCmd

func (Pipeline) AuthACL Uses

func (c Pipeline) AuthACL(ctx context.Context, username, password string) *StatusCmd

Perform an AUTH command, using the given user and pass. Should be used to authenticate the current connection with one of the connections defined in the ACL list when connecting to a Redis 6.0 instance, or greater, that is using the Redis ACL system.

func (Pipeline) BLPop Uses

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

func (Pipeline) BRPop Uses

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

func (Pipeline) BRPopLPush Uses

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

func (Pipeline) BZPopMax Uses

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

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

func (Pipeline) BZPopMin Uses

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

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

func (Pipeline) BgRewriteAOF Uses

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

func (Pipeline) BgSave Uses

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

func (Pipeline) BitCount Uses

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

func (Pipeline) BitField Uses

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

func (Pipeline) BitOpAnd Uses

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

func (Pipeline) BitOpNot Uses

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

func (Pipeline) BitOpOr Uses

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

func (Pipeline) BitOpXor Uses

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

func (Pipeline) BitPos Uses

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

func (Pipeline) ClientGetName Uses

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

ClientGetName returns the name of the connection.

func (Pipeline) ClientID Uses

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

func (Pipeline) ClientKill Uses

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

func (Pipeline) ClientKillByFilter Uses

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

ClientKillByFilter is new style syntax, while the ClientKill is old

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

func (Pipeline) ClientList Uses

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

func (Pipeline) ClientPause Uses

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

func (Pipeline) ClientSetName Uses

func (c Pipeline) ClientSetName(ctx context.Context, name string) *BoolCmd

ClientSetName assigns a name to the connection.

func (Pipeline) ClientUnblock Uses

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

func (Pipeline) ClientUnblockWithError Uses

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

func (*Pipeline) Close Uses

func (c *Pipeline) Close() error

Close closes the pipeline, releasing any open resources.

func (Pipeline) ClusterAddSlots Uses

func (c Pipeline) ClusterAddSlots(ctx context.Context, slots ...int) *StatusCmd

func (Pipeline) ClusterAddSlotsRange Uses

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

func (Pipeline) ClusterCountFailureReports Uses

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

func (Pipeline) ClusterCountKeysInSlot Uses

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

func (Pipeline) ClusterDelSlots Uses

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

func (Pipeline) ClusterDelSlotsRange Uses

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

func (Pipeline) ClusterFailover Uses

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

func (Pipeline) ClusterForget Uses

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

func (Pipeline) ClusterGetKeysInSlot Uses

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

func (Pipeline) ClusterInfo Uses

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

func (Pipeline) ClusterKeySlot Uses

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

func (Pipeline) ClusterMeet Uses

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

func (Pipeline) ClusterNodes Uses

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

func (Pipeline) ClusterReplicate Uses

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

func (Pipeline) ClusterResetHard Uses

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

func (Pipeline) ClusterResetSoft Uses

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

func (Pipeline) ClusterSaveConfig Uses

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

func (Pipeline) ClusterSlaves Uses

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

func (Pipeline) ClusterSlots Uses

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

func (Pipeline) Command Uses

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

func (Pipeline) ConfigGet Uses

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

func (Pipeline) ConfigResetStat Uses

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

func (Pipeline) ConfigRewrite Uses

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

func (Pipeline) ConfigSet Uses

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

func (Pipeline) DBSize Uses

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

func (Pipeline) DebugObject Uses

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

func (Pipeline) Decr Uses

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

func (Pipeline) DecrBy Uses

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

func (Pipeline) Del Uses

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

func (*Pipeline) Discard Uses

func (c *Pipeline) Discard() error

Discard resets the pipeline and discards queued commands.

func (*Pipeline) Do Uses

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

func (Pipeline) Dump Uses

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

func (Pipeline) Echo Uses

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

func (Pipeline) Eval Uses

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

func (Pipeline) EvalSha Uses

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

func (*Pipeline) Exec Uses

func (c *Pipeline) Exec(ctx context.Context) ([]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) Exists Uses

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

func (Pipeline) Expire Uses

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

func (Pipeline) ExpireAt Uses

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

func (Pipeline) FlushAll Uses

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

func (Pipeline) FlushAllAsync Uses

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

func (Pipeline) FlushDB Uses

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

func (Pipeline) FlushDBAsync Uses

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

func (Pipeline) GeoAdd Uses

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

func (Pipeline) GeoDist Uses

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

func (Pipeline) GeoHash Uses

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

func (Pipeline) GeoPos Uses

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

func (Pipeline) GeoRadius Uses

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

GeoRadius is a read-only GEORADIUS_RO command.

func (Pipeline) GeoRadiusByMember Uses

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

GeoRadius is a read-only GEORADIUSBYMEMBER_RO command.

func (Pipeline) GeoRadiusByMemberStore Uses

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

GeoRadiusByMemberStore is a writing GEORADIUSBYMEMBER command.

func (Pipeline) GeoRadiusStore Uses

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

GeoRadiusStore is a writing GEORADIUS command.

func (Pipeline) Get Uses

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

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

func (Pipeline) GetBit Uses

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

func (Pipeline) GetRange Uses

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

func (Pipeline) GetSet Uses

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

func (Pipeline) HDel Uses

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

func (Pipeline) HExists Uses

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

func (Pipeline) HGet Uses

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

func (Pipeline) HGetAll Uses

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

func (Pipeline) HIncrBy Uses

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

func (Pipeline) HIncrByFloat Uses

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

func (Pipeline) HKeys Uses

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

func (Pipeline) HLen Uses

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

func (Pipeline) HMGet Uses

func (c Pipeline) 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 (Pipeline) HMSet Uses

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

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

func (Pipeline) HScan Uses

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

func (Pipeline) HSet Uses

func (c Pipeline) 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 (Pipeline) HSetNX Uses

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

func (Pipeline) HVals Uses

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

func (Pipeline) Incr Uses

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

func (Pipeline) IncrBy Uses

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

func (Pipeline) IncrByFloat Uses

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

func (Pipeline) Info Uses

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

func (Pipeline) Keys Uses

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

func (Pipeline) LIndex Uses

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

func (Pipeline) LInsert Uses

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

func (Pipeline) LInsertAfter Uses

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

func (Pipeline) LInsertBefore Uses

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

func (Pipeline) LLen Uses

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

func (Pipeline) LPop Uses

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

func (Pipeline) LPos Uses

func (c Pipeline) LPos(ctx context.Context, key string, value string, a LPosArgs) *IntCmd

func (Pipeline) LPosCount Uses

func (c Pipeline) LPosCount(ctx context.Context, key string, value string, count int64, a LPosArgs) *IntSliceCmd

func (Pipeline) LPush Uses

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

func (Pipeline) LPushX Uses

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

func (Pipeline) LRange Uses

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

func (Pipeline) LRem Uses

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

func (Pipeline) LSet Uses

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

func (Pipeline) LTrim Uses

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

func (Pipeline) LastSave Uses

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

func (Pipeline) MGet Uses

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

func (Pipeline) MSet Uses

func (c Pipeline) 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 (Pipeline) MSetNX Uses

func (c Pipeline) 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 (Pipeline) MemoryUsage Uses

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

func (Pipeline) Migrate Uses

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

func (Pipeline) Move Uses

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

func (Pipeline) ObjectEncoding Uses

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

func (Pipeline) ObjectIdleTime Uses

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

func (Pipeline) ObjectRefCount Uses

func (c Pipeline) ObjectRefCount(ctx context.Context, key string) *IntCmd

func (Pipeline) PExpire Uses

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

func (Pipeline) PExpireAt Uses

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

func (Pipeline) PFAdd Uses

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

func (Pipeline) PFCount Uses

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

func (Pipeline) PFMerge Uses

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

func (Pipeline) PTTL Uses

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

func (Pipeline) Persist Uses

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

func (Pipeline) Ping Uses

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

func (*Pipeline) Pipeline Uses

func (c *Pipeline) Pipeline() Pipeliner

func (*Pipeline) Pipelined Uses

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

func (*Pipeline) Process Uses

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

Process queues the cmd for later execution.

func (Pipeline) PubSubChannels Uses

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

func (Pipeline) PubSubNumPat Uses

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

func (Pipeline) PubSubNumSub Uses

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

func (Pipeline) Publish Uses

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

Publish posts the message to the channel.

func (Pipeline) Quit Uses

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

func (Pipeline) RPop Uses

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

func (Pipeline) RPopLPush Uses

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

func (Pipeline) RPush Uses

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

func (Pipeline) RPushX Uses

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

func (Pipeline) RandomKey Uses

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

func (Pipeline) ReadOnly Uses

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

func (Pipeline) ReadWrite Uses

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

func (Pipeline) Rename Uses

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

func (Pipeline) RenameNX Uses

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

func (Pipeline) Restore Uses

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

func (Pipeline) RestoreReplace Uses

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

func (Pipeline) SAdd Uses

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

func (Pipeline) SCard Uses

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

func (Pipeline) SDiff Uses

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

func (Pipeline) SDiffStore Uses

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

func (Pipeline) SInter Uses

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

func (Pipeline) SInterStore Uses

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

func (Pipeline) SIsMember Uses

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

func (Pipeline) SMembers Uses

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

Redis `SMEMBERS key` command output as a slice.

func (Pipeline) SMembersMap Uses

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

Redis `SMEMBERS key` command output as a map.

func (Pipeline) SMove Uses

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

func (Pipeline) SPop Uses

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

Redis `SPOP key` command.

func (Pipeline) SPopN Uses

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

Redis `SPOP key count` command.

func (Pipeline) SRandMember Uses

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

Redis `SRANDMEMBER key` command.

func (Pipeline) SRandMemberN Uses

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

Redis `SRANDMEMBER key count` command.

func (Pipeline) SRem Uses

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

func (Pipeline) SScan Uses

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

func (Pipeline) SUnion Uses

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

func (Pipeline) SUnionStore Uses

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

func (Pipeline) Save Uses

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

func (Pipeline) Scan Uses

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

func (Pipeline) ScriptExists Uses

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

func (Pipeline) ScriptFlush Uses

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

func (Pipeline) ScriptKill Uses

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

func (Pipeline) ScriptLoad Uses

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

func (Pipeline) Select Uses

func (c Pipeline) Select(ctx context.Context, index int) *StatusCmd

func (Pipeline) Set Uses

func (c Pipeline) 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 (Pipeline) SetBit Uses

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

func (Pipeline) SetEX Uses

func (c Pipeline) SetEX(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd

Redis `SETEX key expiration value` command.

func (Pipeline) SetNX Uses

func (c Pipeline) 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 (Pipeline) SetRange Uses

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

func (Pipeline) SetXX Uses

func (c Pipeline) 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 (Pipeline) Shutdown Uses

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

func (Pipeline) ShutdownNoSave Uses

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

func (Pipeline) ShutdownSave Uses

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

func (Pipeline) SlaveOf Uses

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

func (Pipeline) SlowLogGet Uses

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

func (Pipeline) Sort Uses

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

func (Pipeline) SortInterfaces Uses

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

func (Pipeline) SortStore Uses

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

func (Pipeline) StrLen Uses

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

func (Pipeline) SwapDB Uses

func (c Pipeline) SwapDB(ctx context.Context, index1, index2 int) *StatusCmd

func (Pipeline) Sync Uses

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

func (Pipeline) TTL Uses

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

func (Pipeline) Time Uses

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

func (Pipeline) Touch Uses

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

func (*Pipeline) TxPipeline Uses

func (c *Pipeline) TxPipeline() Pipeliner

func (*Pipeline) TxPipelined Uses

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

func (Pipeline) Type Uses

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

func (Pipeline) Wait Uses

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

func (Pipeline) XAck Uses

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

func (Pipeline) XAdd Uses

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

func (Pipeline) XClaim Uses

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

func (Pipeline) XClaimJustID Uses