Nil reply Redis returns when key does not exist.
const Nil = proto.Nil
TxFailedErr transaction redis failed.
const TxFailedErr = proto.RedisError("redis: transaction failed")
func SetLogger(logger *log.Logger)
type BitCount struct { Start, End int64 }
type BoolCmd struct {
// contains filtered or unexported fields
}
func NewBoolCmd(args ...interface{}) *BoolCmd
func NewBoolResult(val bool, err error) *BoolCmd
NewBoolResult returns a BoolCmd initialised with val and err for testing
func (cmd *BoolCmd) Args() []interface{}
func (cmd *BoolCmd) Err() error
func (cmd *BoolCmd) Name() string
func (cmd *BoolCmd) Result() (bool, error)
func (cmd *BoolCmd) String() string
func (cmd *BoolCmd) Val() bool
type BoolSliceCmd struct {
// contains filtered or unexported fields
}
func NewBoolSliceCmd(args ...interface{}) *BoolSliceCmd
func NewBoolSliceResult(val []bool, err error) *BoolSliceCmd
NewBoolSliceResult returns a BoolSliceCmd initialised with val and err for testing
func (cmd *BoolSliceCmd) Args() []interface{}
func (cmd *BoolSliceCmd) Err() error
func (cmd *BoolSliceCmd) Name() string
func (cmd *BoolSliceCmd) Result() ([]bool, error)
func (cmd *BoolSliceCmd) String() string
func (cmd *BoolSliceCmd) Val() []bool
Client is a Redis client representing a pool of zero or more underlying connections. It's safe for concurrent use by multiple goroutines.
type Client struct {
// contains filtered or unexported fields
}
▹ Example
func NewClient(opt *Options) *Client
NewClient returns a client to the Redis Server specified by Options.
▹ Example
func NewFailoverClient(failoverOpt *FailoverOptions) *Client
NewFailoverClient returns a Redis client that uses Redis Sentinel for automatic failover. It's safe for concurrent use by multiple goroutines.
▹ Example
func (c *Client) Append(key, value string) *IntCmd
func (c *Client) BLPop(timeout time.Duration, keys ...string) *StringSliceCmd
func (c *Client) BRPop(timeout time.Duration, keys ...string) *StringSliceCmd
func (c *Client) BRPopLPush(source, destination string, timeout time.Duration) *StringCmd
func (c *Client) BZPopMax(timeout time.Duration, keys ...string) *ZWithKeyCmd
Redis `BZPOPMAX key [key ...] timeout` command.
func (c *Client) BZPopMin(timeout time.Duration, keys ...string) *ZWithKeyCmd
Redis `BZPOPMIN key [key ...] timeout` command.
func (c *Client) BgRewriteAOF() *StatusCmd
func (c *Client) BgSave() *StatusCmd
func (c *Client) BitCount(key string, bitCount *BitCount) *IntCmd
func (c *Client) BitOpAnd(destKey string, keys ...string) *IntCmd
func (c *Client) BitOpNot(destKey string, key string) *IntCmd
func (c *Client) BitOpOr(destKey string, keys ...string) *IntCmd
func (c *Client) BitOpXor(destKey string, keys ...string) *IntCmd
func (c *Client) BitPos(key string, bit int64, pos ...int64) *IntCmd
func (c *Client) ClientGetName() *StringCmd
ClientGetName returns the name of the connection.
func (c *Client) ClientID() *IntCmd
func (c *Client) ClientKill(ipPort string) *StatusCmd
func (c *Client) ClientKillByFilter(keys ...string) *IntCmd
ClientKillByFilter is new style synx, while the ClientKill is old CLIENT KILL <option> [value] ... <option> [value]
func (c *Client) ClientList() *StringCmd
func (c *Client) ClientPause(dur time.Duration) *BoolCmd
func (c *Client) ClientUnblock(id int64) *IntCmd
func (c *Client) ClientUnblockWithError(id int64) *IntCmd
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 (c *Client) ClusterAddSlots(slots ...int) *StatusCmd
func (c *Client) ClusterAddSlotsRange(min, max int) *StatusCmd
func (c *Client) ClusterCountFailureReports(nodeID string) *IntCmd
func (c *Client) ClusterCountKeysInSlot(slot int) *IntCmd
func (c *Client) ClusterDelSlots(slots ...int) *StatusCmd
func (c *Client) ClusterDelSlotsRange(min, max int) *StatusCmd
func (c *Client) ClusterFailover() *StatusCmd
func (c *Client) ClusterForget(nodeID string) *StatusCmd
func (c *Client) ClusterGetKeysInSlot(slot int, count int) *StringSliceCmd
func (c *Client) ClusterInfo() *StringCmd
func (c *Client) ClusterKeySlot(key string) *IntCmd
func (c *Client) ClusterMeet(host, port string) *StatusCmd
func (c *Client) ClusterNodes() *StringCmd
func (c *Client) ClusterReplicate(nodeID string) *StatusCmd
func (c *Client) ClusterResetHard() *StatusCmd
func (c *Client) ClusterResetSoft() *StatusCmd
func (c *Client) ClusterSaveConfig() *StatusCmd
func (c *Client) ClusterSlaves(nodeID string) *StringSliceCmd
func (c *Client) ClusterSlots() *ClusterSlotsCmd
func (c *Client) Command() *CommandsInfoCmd
func (c *Client) ConfigGet(parameter string) *SliceCmd
func (c *Client) ConfigResetStat() *StatusCmd
func (c *Client) ConfigRewrite() *StatusCmd
func (c *Client) ConfigSet(parameter, value string) *StatusCmd
func (c *Client) Context() context.Context
func (c *Client) DBSize() *IntCmd
func (c *Client) DbSize() *IntCmd
Deperecated. Use DBSize instead.
func (c *Client) DebugObject(key string) *StringCmd
func (c *Client) Decr(key string) *IntCmd
func (c *Client) DecrBy(key string, decrement int64) *IntCmd
func (c *Client) Del(keys ...string) *IntCmd
func (c *Client) Do(args ...interface{}) *Cmd
Do creates a Cmd from the args and processes the cmd.
func (c *Client) Dump(key string) *StringCmd
func (c *Client) Echo(message interface{}) *StringCmd
func (c *Client) Eval(script string, keys []string, args ...interface{}) *Cmd
func (c *Client) EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd
func (c *Client) Exists(keys ...string) *IntCmd
func (c *Client) Expire(key string, expiration time.Duration) *BoolCmd
func (c *Client) ExpireAt(key string, tm time.Time) *BoolCmd
func (c *Client) FlushAll() *StatusCmd
func (c *Client) FlushAllAsync() *StatusCmd
func (c *Client) FlushDB() *StatusCmd
func (c *Client) FlushDBAsync() *StatusCmd
func (c *Client) FlushDb() *StatusCmd
Deprecated. Use FlushDB instead.
func (c *Client) GeoAdd(key string, geoLocation ...*GeoLocation) *IntCmd
func (c *Client) GeoDist(key string, member1, member2, unit string) *FloatCmd
func (c *Client) GeoHash(key string, members ...string) *StringSliceCmd
func (c *Client) GeoPos(key string, members ...string) *GeoPosCmd
func (c *Client) GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd
func (c *Client) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) *GeoLocationCmd
func (c *Client) GeoRadiusByMemberRO(key, member string, query *GeoRadiusQuery) *GeoLocationCmd
func (c *Client) GeoRadiusRO(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd
func (c *Client) Get(key string) *StringCmd
Redis `GET key` command. It returns redis.Nil error when key does not exist.
func (c *Client) GetBit(key string, offset int64) *IntCmd
func (c *Client) GetRange(key string, start, end int64) *StringCmd
func (c *Client) GetSet(key string, value interface{}) *StringCmd
func (c *Client) HDel(key string, fields ...string) *IntCmd
func (c *Client) HExists(key, field string) *BoolCmd
func (c *Client) HGet(key, field string) *StringCmd
func (c *Client) HGetAll(key string) *StringStringMapCmd
func (c *Client) HIncrBy(key, field string, incr int64) *IntCmd
func (c *Client) HIncrByFloat(key, field string, incr float64) *FloatCmd
func (c *Client) HKeys(key string) *StringSliceCmd
func (c *Client) HLen(key string) *IntCmd
func (c *Client) HMGet(key string, fields ...string) *SliceCmd
func (c *Client) HMSet(key string, fields map[string]interface{}) *StatusCmd
func (c *Client) HScan(key string, cursor uint64, match string, count int64) *ScanCmd
func (c *Client) HSet(key, field string, value interface{}) *BoolCmd
func (c *Client) HSetNX(key, field string, value interface{}) *BoolCmd
func (c *Client) HVals(key string) *StringSliceCmd
func (c *Client) Incr(key string) *IntCmd
func (c *Client) IncrBy(key string, value int64) *IntCmd
func (c *Client) IncrByFloat(key string, value float64) *FloatCmd
func (c *Client) Info(section ...string) *StringCmd
func (c *Client) Keys(pattern string) *StringSliceCmd
func (c *Client) LIndex(key string, index int64) *StringCmd
func (c *Client) LInsert(key, op string, pivot, value interface{}) *IntCmd
func (c *Client) LInsertAfter(key string, pivot, value interface{}) *IntCmd
func (c *Client) LInsertBefore(key string, pivot, value interface{}) *IntCmd
func (c *Client) LLen(key string) *IntCmd
func (c *Client) LPop(key string) *StringCmd
func (c *Client) LPush(key string, values ...interface{}) *IntCmd
func (c *Client) LPushX(key string, value interface{}) *IntCmd
func (c *Client) LRange(key string, start, stop int64) *StringSliceCmd
func (c *Client) LRem(key string, count int64, value interface{}) *IntCmd
func (c *Client) LSet(key string, index int64, value interface{}) *StatusCmd
func (c *Client) LTrim(key string, start, stop int64) *StatusCmd
func (c *Client) LastSave() *IntCmd
func (c *Client) MGet(keys ...string) *SliceCmd
func (c *Client) MSet(pairs ...interface{}) *StatusCmd
func (c *Client) MSetNX(pairs ...interface{}) *BoolCmd
func (c *Client) MemoryUsage(key string, samples ...int) *IntCmd
func (c *Client) Migrate(host, port, key string, db int64, timeout time.Duration) *StatusCmd
func (c *Client) Move(key string, db int64) *BoolCmd
func (c *Client) ObjectEncoding(key string) *StringCmd
func (c *Client) ObjectIdleTime(key string) *DurationCmd
func (c *Client) ObjectRefCount(key string) *IntCmd
func (c *Client) Options() *Options
Options returns read-only Options that were used to create the client.
func (c *Client) PExpire(key string, expiration time.Duration) *BoolCmd
func (c *Client) PExpireAt(key string, tm time.Time) *BoolCmd
func (c *Client) PFAdd(key string, els ...interface{}) *IntCmd
func (c *Client) PFCount(keys ...string) *IntCmd
func (c *Client) PFMerge(dest string, keys ...string) *StatusCmd
func (c *Client) PSubscribe(channels ...string) *PubSub
PSubscribe subscribes the client to the given patterns. Patterns can be omitted to create empty subscription.
func (c *Client) PTTL(key string) *DurationCmd
func (c *Client) Persist(key string) *BoolCmd
func (c *Client) Ping() *StatusCmd
func (c *Client) Pipeline() Pipeliner
▹ Example
func (c *Client) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)
▹ Example
func (c *Client) PoolStats() *PoolStats
PoolStats returns connection pool stats.
func (c *Client) Process(cmd Cmder) error
func (c *Client) PubSubChannels(pattern string) *StringSliceCmd
func (c *Client) PubSubNumPat() *IntCmd
func (c *Client) PubSubNumSub(channels ...string) *StringIntMapCmd
func (c *Client) Publish(channel string, message interface{}) *IntCmd
Publish posts the message to the channel.
func (c *Client) Quit() *StatusCmd
func (c *Client) RPop(key string) *StringCmd
func (c *Client) RPopLPush(source, destination string) *StringCmd
func (c *Client) RPush(key string, values ...interface{}) *IntCmd
func (c *Client) RPushX(key string, value interface{}) *IntCmd
func (c *Client) RandomKey() *StringCmd
func (c *Client) ReadOnly() *StatusCmd
func (c *Client) ReadWrite() *StatusCmd
func (c *Client) Rename(key, newkey string) *StatusCmd
func (c *Client) RenameNX(key, newkey string) *BoolCmd
func (c *Client) Restore(key string, ttl time.Duration, value string) *StatusCmd
func (c *Client) RestoreReplace(key string, ttl time.Duration, value string) *StatusCmd
func (c *Client) SAdd(key string, members ...interface{}) *IntCmd
func (c *Client) SCard(key string) *IntCmd
func (c *Client) SDiff(keys ...string) *StringSliceCmd
func (c *Client) SDiffStore(destination string, keys ...string) *IntCmd
func (c *Client) SInter(keys ...string) *StringSliceCmd
func (c *Client) SInterStore(destination string, keys ...string) *IntCmd
func (c *Client) SIsMember(key string, member interface{}) *BoolCmd
func (c *Client) SMembers(key string) *StringSliceCmd
Redis `SMEMBERS key` command output as a slice
func (c *Client) SMembersMap(key string) *StringStructMapCmd
Redis `SMEMBERS key` command output as a map
func (c *Client) SMove(source, destination string, member interface{}) *BoolCmd
func (c *Client) SPop(key string) *StringCmd
Redis `SPOP key` command.
func (c *Client) SPopN(key string, count int64) *StringSliceCmd
Redis `SPOP key count` command.
func (c *Client) SRandMember(key string) *StringCmd
Redis `SRANDMEMBER key` command.
func (c *Client) SRandMemberN(key string, count int64) *StringSliceCmd
Redis `SRANDMEMBER key count` command.
func (c *Client) SRem(key string, members ...interface{}) *IntCmd
func (c *Client) SScan(key string, cursor uint64, match string, count int64) *ScanCmd
func (c *Client) SUnion(keys ...string) *StringSliceCmd
func (c *Client) SUnionStore(destination string, keys ...string) *IntCmd
func (c *Client) Save() *StatusCmd
func (c *Client) Scan(cursor uint64, match string, count int64) *ScanCmd
func (c *Client) ScriptExists(hashes ...string) *BoolSliceCmd
func (c *Client) ScriptFlush() *StatusCmd
func (c *Client) ScriptKill() *StatusCmd
func (c *Client) ScriptLoad(script string) *StringCmd
func (c *Client) Set(key string, value interface{}, expiration time.Duration) *StatusCmd
Redis `SET key value [expiration]` command.
Use expiration for `SETEX`-like behavior. Zero expiration means the key has no expiration time.
func (c *Client) SetBit(key string, offset int64, value int) *IntCmd
func (c *Client) SetLimiter(l Limiter) *Client
func (c *Client) SetNX(key string, value interface{}, expiration time.Duration) *BoolCmd
Redis `SET key value [expiration] NX` command.
Zero expiration means the key has no expiration time.
func (c *Client) SetRange(key string, offset int64, value string) *IntCmd
func (c *Client) SetXX(key string, value interface{}, expiration time.Duration) *BoolCmd
Redis `SET key value [expiration] XX` command.
Zero expiration means the key has no expiration time.
func (c *Client) Shutdown() *StatusCmd
func (c *Client) ShutdownNoSave() *StatusCmd
func (c *Client) ShutdownSave() *StatusCmd
func (c *Client) SlaveOf(host, port string) *StatusCmd
func (c *Client) SlowLog()
func (c *Client) Sort(key string, sort *Sort) *StringSliceCmd
func (c *Client) SortInterfaces(key string, sort *Sort) *SliceCmd
func (c *Client) SortStore(key, store string, sort *Sort) *IntCmd
func (c *Client) StrLen(key string) *IntCmd
func (c *Client) String() string
func (c *Client) Subscribe(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 (c *Client) Sync()
func (c *Client) TTL(key string) *DurationCmd
func (c *Client) Time() *TimeCmd
func (c *Client) Touch(keys ...string) *IntCmd
func (c *Client) TxPipeline() Pipeliner
TxPipeline acts like Pipeline, but wraps queued commands with MULTI/EXEC.
▹ Example
func (c *Client) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error)
▹ Example
func (c *Client) Type(key string) *StatusCmd
func (c *Client) Unlink(keys ...string) *IntCmd
func (c *Client) Wait(numSlaves int, timeout time.Duration) *IntCmd
func (c *Client) Watch(fn func(*Tx) error, keys ...string) error
Watch prepares a transaction and marks the keys to be watched for conditional execution if there are any keys.
The transaction is automatically closed when fn exits.
▹ Example
func (c *Client) WithContext(ctx context.Context) *Client
func (c *Client) WrapProcess( fn func(oldProcess func(cmd Cmder) error) func(cmd Cmder) error, )
WrapProcess wraps function that processes Redis commands.
func (c *Client) WrapProcessPipeline( fn func(oldProcess func([]Cmder) error) func([]Cmder) error, )
func (c *Client) XAck(stream, group string, ids ...string) *IntCmd
func (c *Client) XAdd(a *XAddArgs) *StringCmd
func (c *Client) XClaim(a *XClaimArgs) *XMessageSliceCmd
func (c *Client) XClaimJustID(a *XClaimArgs) *StringSliceCmd
func (c *Client) XDel(stream string, ids ...string) *IntCmd
func (c *Client) XGroupCreate(stream, group, start string) *StatusCmd
func (c *Client) XGroupCreateMkStream(stream, group, start string) *StatusCmd
func (c *Client) XGroupDelConsumer(stream, group, consumer string) *IntCmd
func (c *Client) XGroupDestroy(stream, group string) *IntCmd
func (c *Client) XGroupSetID(stream, group, start string) *StatusCmd
func (c *Client) XLen(stream string) *IntCmd
func (c *Client) XPending(stream, group string) *XPendingCmd
func (c *Client) XPendingExt(a *XPendingExtArgs) *XPendingExtCmd
func (c *Client) XRange(stream, start, stop string) *XMessageSliceCmd
func (c *Client) XRangeN(stream, start, stop string, count int64) *XMessageSliceCmd
func (c *Client) XRead(a *XReadArgs) *XStreamSliceCmd
func (c *Client) XReadGroup(a *XReadGroupArgs) *XStreamSliceCmd
func (c *Client) XReadStreams(streams ...string) *XStreamSliceCmd
func (c *Client) XRevRange(stream, start, stop string) *XMessageSliceCmd
func (c *Client) XRevRangeN(stream, start, stop string, count int64) *XMessageSliceCmd
func (c *Client) XTrim(key string, maxLen int64) *IntCmd
func (c *Client) XTrimApprox(key string, maxLen int64) *IntCmd
func (c *Client) ZAdd(key string, members ...Z) *IntCmd
Redis `ZADD key score member [score member ...]` command.
func (c *Client) ZAddCh(key string, members ...Z) *IntCmd
Redis `ZADD key CH score member [score member ...]` command.
func (c *Client) ZAddNX(key string, members ...Z) *IntCmd
Redis `ZADD key NX score member [score member ...]` command.
func (c *Client) ZAddNXCh(key string, members ...Z) *IntCmd
Redis `ZADD key NX CH score member [score member ...]` command.
func (c *Client) ZAddXX(key string, members ...Z) *IntCmd
Redis `ZADD key XX score member [score member ...]` command.
func (c *Client) ZAddXXCh(key string, members ...Z) *IntCmd
Redis `ZADD key XX CH score member [score member ...]` command.
func (c *Client) ZCard(key string) *IntCmd
func (c *Client) ZCount(key, min, max string) *IntCmd
func (c *Client) ZIncr(key string, member Z) *FloatCmd
Redis `ZADD key INCR score member` command.
func (c *Client) ZIncrBy(key string, increment float64, member string) *FloatCmd
func (c *Client) ZIncrNX(key string, member Z) *FloatCmd
Redis `ZADD key NX INCR score member` command.
func (c *Client) ZIncrXX(key string, member Z) *FloatCmd
Redis `ZADD key XX INCR score member` command.
func (c *Client) ZInterStore(destination string, store ZStore, keys ...string) *IntCmd
func (c *Client) ZLexCount(key, min, max string) *IntCmd
func (c *Client) ZPopMax(key string, count ...int64) *ZSliceCmd
func (c *Client) ZPopMin(key string, count ...int64) *ZSliceCmd
func (c *Client) ZRange(key string, start, stop int64) *StringSliceCmd
func (c *Client) ZRangeByLex(key string, opt ZRangeBy) *StringSliceCmd
func (c *Client) ZRangeByScore(key string, opt ZRangeBy) *StringSliceCmd
func (c *Client) ZRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd
func (c *Client) ZRangeWithScores(key string, start, stop int64) *ZSliceCmd
func (c *Client) ZRank(key, member string) *IntCmd
func (c *Client) ZRem(key string, members ...interface{}) *IntCmd
func (c *Client) ZRemRangeByLex(key, min, max string) *IntCmd
func (c *Client) ZRemRangeByRank(key string, start, stop int64) *IntCmd
func (c *Client) ZRemRangeByScore(key, min, max string) *IntCmd
func (c *Client) ZRevRange(key string, start, stop int64) *StringSliceCmd
func (c *Client) ZRevRangeByLex(key string, opt ZRangeBy) *StringSliceCmd
func (c *Client) ZRevRangeByScore(key string, opt ZRangeBy) *StringSliceCmd
func (c *Client) ZRevRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd
func (c *Client) ZRevRangeWithScores(key string, start, stop int64) *ZSliceCmd
func (c *Client) ZRevRank(key, member string) *IntCmd
func (c *Client) ZScan(key string, cursor uint64, match string, count int64) *ScanCmd
func (c *Client) ZScore(key, member string) *FloatCmd
func (c *Client) ZUnionStore(dest string, store ZStore, keys ...string) *IntCmd
ClusterClient is a Redis Cluster client representing a pool of zero or more underlying connections. It's safe for concurrent use by multiple goroutines.
type ClusterClient struct {
// contains filtered or unexported fields
}
func NewClusterClient(opt *ClusterOptions) *ClusterClient
NewClusterClient returns a Redis Cluster client as described in http://redis.io/topics/cluster-spec.
▹ Example
▹ Example (ManualSetup)
func (c *ClusterClient) Append(key, value string) *IntCmd
func (c *ClusterClient) BLPop(timeout time.Duration, keys ...string) *StringSliceCmd
func (c *ClusterClient) BRPop(timeout time.Duration, keys ...string) *StringSliceCmd
func (c *ClusterClient) BRPopLPush(source, destination string, timeout time.Duration) *StringCmd
func (c *ClusterClient) BZPopMax(timeout time.Duration, keys ...string) *ZWithKeyCmd
Redis `BZPOPMAX key [key ...] timeout` command.
func (c *ClusterClient) BZPopMin(timeout time.Duration, keys ...string) *ZWithKeyCmd
Redis `BZPOPMIN key [key ...] timeout` command.
func (c *ClusterClient) BgRewriteAOF() *StatusCmd
func (c *ClusterClient) BgSave() *StatusCmd
func (c *ClusterClient) BitCount(key string, bitCount *BitCount) *IntCmd
func (c *ClusterClient) BitOpAnd(destKey string, keys ...string) *IntCmd
func (c *ClusterClient) BitOpNot(destKey string, key string) *IntCmd
func (c *ClusterClient) BitOpOr(destKey string, keys ...string) *IntCmd
func (c *ClusterClient) BitOpXor(destKey string, keys ...string) *IntCmd
func (c *ClusterClient) BitPos(key string, bit int64, pos ...int64) *IntCmd
func (c *ClusterClient) ClientGetName() *StringCmd
ClientGetName returns the name of the connection.
func (c *ClusterClient) ClientID() *IntCmd
func (c *ClusterClient) ClientKill(ipPort string) *StatusCmd
func (c *ClusterClient) ClientKillByFilter(keys ...string) *IntCmd
ClientKillByFilter is new style synx, while the ClientKill is old CLIENT KILL <option> [value] ... <option> [value]
func (c *ClusterClient) ClientList() *StringCmd
func (c *ClusterClient) ClientPause(dur time.Duration) *BoolCmd
func (c *ClusterClient) ClientUnblock(id int64) *IntCmd
func (c *ClusterClient) ClientUnblockWithError(id int64) *IntCmd
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 (c *ClusterClient) ClusterAddSlots(slots ...int) *StatusCmd
func (c *ClusterClient) ClusterAddSlotsRange(min, max int) *StatusCmd
func (c *ClusterClient) ClusterCountFailureReports(nodeID string) *IntCmd
func (c *ClusterClient) ClusterCountKeysInSlot(slot int) *IntCmd
func (c *ClusterClient) ClusterDelSlots(slots ...int) *StatusCmd
func (c *ClusterClient) ClusterDelSlotsRange(min, max int) *StatusCmd
func (c *ClusterClient) ClusterFailover() *StatusCmd
func (c *ClusterClient) ClusterForget(nodeID string) *StatusCmd
func (c *ClusterClient) ClusterGetKeysInSlot(slot int, count int) *StringSliceCmd
func (c *ClusterClient) ClusterInfo() *StringCmd
func (c *ClusterClient) ClusterKeySlot(key string) *IntCmd
func (c *ClusterClient) ClusterMeet(host, port string) *StatusCmd
func (c *ClusterClient) ClusterNodes() *StringCmd
func (c *ClusterClient) ClusterReplicate(nodeID string) *StatusCmd
func (c *ClusterClient) ClusterResetHard() *StatusCmd
func (c *ClusterClient) ClusterResetSoft() *StatusCmd
func (c *ClusterClient) ClusterSaveConfig() *StatusCmd
func (c *ClusterClient) ClusterSlaves(nodeID string) *StringSliceCmd
func (c *ClusterClient) ClusterSlots() *ClusterSlotsCmd
func (c *ClusterClient) Command() *CommandsInfoCmd
func (c *ClusterClient) ConfigGet(parameter string) *SliceCmd
func (c *ClusterClient) ConfigResetStat() *StatusCmd
func (c *ClusterClient) ConfigRewrite() *StatusCmd
func (c *ClusterClient) ConfigSet(parameter, value string) *StatusCmd
func (c *ClusterClient) Context() context.Context
func (c *ClusterClient) DBSize() *IntCmd
func (c *ClusterClient) DbSize() *IntCmd
Deperecated. Use DBSize instead.
func (c *ClusterClient) DebugObject(key string) *StringCmd
func (c *ClusterClient) Decr(key string) *IntCmd
func (c *ClusterClient) DecrBy(key string, decrement int64) *IntCmd
func (c *ClusterClient) Del(keys ...string) *IntCmd
func (c *ClusterClient) Do(args ...interface{}) *Cmd
Do creates a Cmd from the args and processes the cmd.
func (c *ClusterClient) Dump(key string) *StringCmd
func (c *ClusterClient) Echo(message interface{}) *StringCmd
func (c *ClusterClient) Eval(script string, keys []string, args ...interface{}) *Cmd
func (c *ClusterClient) EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd
func (c *ClusterClient) Exists(keys ...string) *IntCmd
func (c *ClusterClient) Expire(key string, expiration time.Duration) *BoolCmd
func (c *ClusterClient) ExpireAt(key string, tm time.Time) *BoolCmd
func (c *ClusterClient) FlushAll() *StatusCmd
func (c *ClusterClient) FlushAllAsync() *StatusCmd
func (c *ClusterClient) FlushDB() *StatusCmd
func (c *ClusterClient) FlushDBAsync() *StatusCmd
func (c *ClusterClient) FlushDb() *StatusCmd
Deprecated. Use FlushDB instead.
func (c *ClusterClient) ForEachMaster(fn func(client *Client) error) error
ForEachMaster concurrently calls the fn on each master node in the cluster. It returns the first error if any.
func (c *ClusterClient) ForEachNode(fn func(client *Client) error) error
ForEachNode concurrently calls the fn on each known node in the cluster. It returns the first error if any.
func (c *ClusterClient) ForEachSlave(fn func(client *Client) error) error
ForEachSlave concurrently calls the fn on each slave node in the cluster. It returns the first error if any.
func (c *ClusterClient) GeoAdd(key string, geoLocation ...*GeoLocation) *IntCmd
func (c *ClusterClient) GeoDist(key string, member1, member2, unit string) *FloatCmd
func (c *ClusterClient) GeoHash(key string, members ...string) *StringSliceCmd
func (c *ClusterClient) GeoPos(key string, members ...string) *GeoPosCmd
func (c *ClusterClient) GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd
func (c *ClusterClient) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) *GeoLocationCmd
func (c *ClusterClient) GeoRadiusByMemberRO(key, member string, query *GeoRadiusQuery) *GeoLocationCmd
func (c *ClusterClient) GeoRadiusRO(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd
func (c *ClusterClient) Get(key string) *StringCmd
Redis `GET key` command. It returns redis.Nil error when key does not exist.
func (c *ClusterClient) GetBit(key string, offset int64) *IntCmd
func (c *ClusterClient) GetRange(key string, start, end int64) *StringCmd
func (c *ClusterClient) GetSet(key string, value interface{}) *StringCmd
func (c *ClusterClient) HDel(key string, fields ...string) *IntCmd
func (c *ClusterClient) HExists(key, field string) *BoolCmd
func (c *ClusterClient) HGet(key, field string) *StringCmd
func (c *ClusterClient) HGetAll(key string) *StringStringMapCmd
func (c *ClusterClient) HIncrBy(key, field string, incr int64) *IntCmd
func (c *ClusterClient) HIncrByFloat(key, field string, incr float64) *FloatCmd
func (c *ClusterClient) HKeys(key string) *StringSliceCmd
func (c *ClusterClient) HLen(key string) *IntCmd
func (c *ClusterClient) HMGet(key string, fields ...string) *SliceCmd
func (c *ClusterClient) HMSet(key string, fields map[string]interface{}) *StatusCmd
func (c *ClusterClient) HScan(key string, cursor uint64, match string, count int64) *ScanCmd
func (c *ClusterClient) HSet(key, field string, value interface{}) *BoolCmd
func (c *ClusterClient) HSetNX(key, field string, value interface{}) *BoolCmd
func (c *ClusterClient) HVals(key string) *StringSliceCmd
func (c *ClusterClient) Incr(key string) *IntCmd
func (c *ClusterClient) IncrBy(key string, value int64) *IntCmd
func (c *ClusterClient) IncrByFloat(key string, value float64) *FloatCmd
func (c *ClusterClient) Info(section ...string) *StringCmd
func (c *ClusterClient) Keys(pattern string) *StringSliceCmd
func (c *ClusterClient) LIndex(key string, index int64) *StringCmd
func (c *ClusterClient) LInsert(key, op string, pivot, value interface{}) *IntCmd
func (c *ClusterClient) LInsertAfter(key string, pivot, value interface{}) *IntCmd
func (c *ClusterClient) LInsertBefore(key string, pivot, value interface{}) *IntCmd
func (c *ClusterClient) LLen(key string) *IntCmd
func (c *ClusterClient) LPop(key string) *StringCmd
func (c *ClusterClient) LPush(key string, values ...interface{}) *IntCmd
func (c *ClusterClient) LPushX(key string, value interface{}) *IntCmd
func (c *ClusterClient) LRange(key string, start, stop int64) *StringSliceCmd
func (c *ClusterClient) LRem(key string, count int64, value interface{}) *IntCmd
func (c *ClusterClient) LSet(key string, index int64, value interface{}) *StatusCmd
func (c *ClusterClient) LTrim(key string, start, stop int64) *StatusCmd
func (c *ClusterClient) LastSave() *IntCmd
func (c *ClusterClient) MGet(keys ...string) *SliceCmd
func (c *ClusterClient) MSet(pairs ...interface{}) *StatusCmd
func (c *ClusterClient) MSetNX(pairs ...interface{}) *BoolCmd
func (c *ClusterClient) MemoryUsage(key string, samples ...int) *IntCmd
func (c *ClusterClient) Migrate(host, port, key string, db int64, timeout time.Duration) *StatusCmd
func (c *ClusterClient) Move(key string, db int64) *BoolCmd
func (c *ClusterClient) ObjectEncoding(key string) *StringCmd
func (c *ClusterClient) ObjectIdleTime(key string) *DurationCmd
func (c *ClusterClient) ObjectRefCount(key string) *IntCmd
func (c *ClusterClient) Options() *ClusterOptions
Options returns read-only Options that were used to create the client.
func (c *ClusterClient) PExpire(key string, expiration time.Duration) *BoolCmd
func (c *ClusterClient) PExpireAt(key string, tm time.Time) *BoolCmd
func (c *ClusterClient) PFAdd(key string, els ...interface{}) *IntCmd
func (c *ClusterClient) PFCount(keys ...string) *IntCmd
func (c *ClusterClient) PFMerge(dest string, keys ...string) *StatusCmd
func (c *ClusterClient) PSubscribe(channels ...string) *PubSub
PSubscribe subscribes the client to the given patterns. Patterns can be omitted to create empty subscription.
func (c *ClusterClient) PTTL(key string) *DurationCmd
func (c *ClusterClient) Persist(key string) *BoolCmd
func (c *ClusterClient) Ping() *StatusCmd
func (c *ClusterClient) Pipeline() Pipeliner
func (c *ClusterClient) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)
func (c *ClusterClient) PoolStats() *PoolStats
PoolStats returns accumulated connection pool stats.
func (c *ClusterClient) Process(cmd Cmder) error
func (c *ClusterClient) PubSubChannels(pattern string) *StringSliceCmd
func (c *ClusterClient) PubSubNumPat() *IntCmd
func (c *ClusterClient) PubSubNumSub(channels ...string) *StringIntMapCmd
func (c *ClusterClient) Publish(channel string, message interface{}) *IntCmd
Publish posts the message to the channel.
func (c *ClusterClient) Quit() *StatusCmd
func (c *ClusterClient) RPop(key string) *StringCmd
func (c *ClusterClient) RPopLPush(source, destination string) *StringCmd
func (c *ClusterClient) RPush(key string, values ...interface{}) *IntCmd
func (c *ClusterClient) RPushX(key string, value interface{}) *IntCmd
func (c *ClusterClient) RandomKey() *StringCmd
func (c *ClusterClient) ReadOnly() *StatusCmd
func (c *ClusterClient) ReadWrite() *StatusCmd
func (c *ClusterClient) ReloadState() error
ReloadState reloads cluster state. If available it calls ClusterSlots func to get cluster slots information.
func (c *ClusterClient) Rename(key, newkey string) *StatusCmd
func (c *ClusterClient) RenameNX(key, newkey string) *BoolCmd
func (c *ClusterClient) Restore(key string, ttl time.Duration, value string) *StatusCmd
func (c *ClusterClient) RestoreReplace(key string, ttl time.Duration, value string) *StatusCmd
func (c *ClusterClient) SAdd(key string, members ...interface{}) *IntCmd
func (c *ClusterClient) SCard(key string) *IntCmd
func (c *ClusterClient) SDiff(keys ...string) *StringSliceCmd
func (c *ClusterClient) SDiffStore(destination string, keys ...string) *IntCmd
func (c *ClusterClient) SInter(keys ...string) *StringSliceCmd
func (c *ClusterClient) SInterStore(destination string, keys ...string) *IntCmd
func (c *ClusterClient) SIsMember(key string, member interface{}) *BoolCmd
func (c *ClusterClient) SMembers(key string) *StringSliceCmd
Redis `SMEMBERS key` command output as a slice
func (c *ClusterClient) SMembersMap(key string) *StringStructMapCmd
Redis `SMEMBERS key` command output as a map
func (c *ClusterClient) SMove(source, destination string, member interface{}) *BoolCmd
func (c *ClusterClient) SPop(key string) *StringCmd
Redis `SPOP key` command.
func (c *ClusterClient) SPopN(key string, count int64) *StringSliceCmd
Redis `SPOP key count` command.
func (c *ClusterClient) SRandMember(key string) *StringCmd
Redis `SRANDMEMBER key` command.
func (c *ClusterClient) SRandMemberN(key string, count int64) *StringSliceCmd
Redis `SRANDMEMBER key count` command.
func (c *ClusterClient) SRem(key string, members ...interface{}) *IntCmd
func (c *ClusterClient) SScan(key string, cursor uint64, match string, count int64) *ScanCmd
func (c *ClusterClient) SUnion(keys ...string) *StringSliceCmd
func (c *ClusterClient) SUnionStore(destination string, keys ...string) *IntCmd
func (c *ClusterClient) Save() *StatusCmd
func (c *ClusterClient) Scan(cursor uint64, match string, count int64) *ScanCmd
func (c *ClusterClient) ScriptExists(hashes ...string) *BoolSliceCmd
func (c *ClusterClient) ScriptFlush() *StatusCmd
func (c *ClusterClient) ScriptKill() *StatusCmd
func (c *ClusterClient) ScriptLoad(script string) *StringCmd
func (c *ClusterClient) Set(key string, value interface{}, expiration time.Duration) *StatusCmd
Redis `SET key value [expiration]` command.
Use expiration for `SETEX`-like behavior. Zero expiration means the key has no expiration time.
func (c *ClusterClient) SetBit(key string, offset int64, value int) *IntCmd
func (c *ClusterClient) SetNX(key string, value interface{}, expiration time.Duration) *BoolCmd
Redis `SET key value [expiration] NX` command.
Zero expiration means the key has no expiration time.
func (c *ClusterClient) SetRange(key string, offset int64, value string) *IntCmd
func (c *ClusterClient) SetXX(key string, value interface{}, expiration time.Duration) *BoolCmd
Redis `SET key value [expiration] XX` command.
Zero expiration means the key has no expiration time.
func (c *ClusterClient) Shutdown() *StatusCmd
func (c *ClusterClient) ShutdownNoSave() *StatusCmd
func (c *ClusterClient) ShutdownSave() *StatusCmd
func (c *ClusterClient) SlaveOf(host, port string) *StatusCmd
func (c *ClusterClient) SlowLog()
func (c *ClusterClient) Sort(key string, sort *Sort) *StringSliceCmd
func (c *ClusterClient) SortInterfaces(key string, sort *Sort) *SliceCmd
func (c *ClusterClient) SortStore(key, store string, sort *Sort) *IntCmd
func (c *ClusterClient) StrLen(key string) *IntCmd
func (c *ClusterClient) Subscribe(channels ...string) *PubSub
Subscribe subscribes the client to the specified channels. Channels can be omitted to create empty subscription.
func (c *ClusterClient) Sync()
func (c *ClusterClient) TTL(key string) *DurationCmd
func (c *ClusterClient) Time() *TimeCmd
func (c *ClusterClient) Touch(keys ...string) *IntCmd
func (c *ClusterClient) TxPipeline() Pipeliner
TxPipeline acts like Pipeline, but wraps queued commands with MULTI/EXEC.
func (c *ClusterClient) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error)
func (c *ClusterClient) Type(key string) *StatusCmd
func (c *ClusterClient) Unlink(keys ...string) *IntCmd
func (c *ClusterClient) Wait(numSlaves int, timeout time.Duration) *IntCmd
func (c *ClusterClient) Watch(fn func(*Tx) error, keys ...string) error
func (c *ClusterClient) WithContext(ctx context.Context) *ClusterClient
func (c *ClusterClient) WrapProcess( fn func(oldProcess func(Cmder) error) func(Cmder) error, )
func (c *ClusterClient) WrapProcessPipeline( fn func(oldProcess func([]Cmder) error) func([]Cmder) error, )
func (c *ClusterClient) XAck(stream, group string, ids ...string) *IntCmd
func (c *ClusterClient) XAdd(a *XAddArgs) *StringCmd
func (c *ClusterClient) XClaim(a *XClaimArgs) *XMessageSliceCmd
func (c *ClusterClient) XClaimJustID(a *XClaimArgs) *StringSliceCmd
func (c *ClusterClient) XDel(stream string, ids ...string) *IntCmd
func (c *ClusterClient) XGroupCreate(stream, group, start string) *StatusCmd
func (c *ClusterClient) XGroupCreateMkStream(stream, group, start string) *StatusCmd
func (c *ClusterClient) XGroupDelConsumer(stream, group, consumer string) *IntCmd
func (c *ClusterClient) XGroupDestroy(stream, group string) *IntCmd
func (c *ClusterClient) XGroupSetID(stream, group, start string) *StatusCmd
func (c *ClusterClient) XLen(stream string) *IntCmd
func (c *ClusterClient) XPending(stream, group string) *XPendingCmd
func (c *ClusterClient) XPendingExt(a *XPendingExtArgs) *XPendingExtCmd
func (c *ClusterClient) XRange(stream, start, stop string) *XMessageSliceCmd
func (c *ClusterClient) XRangeN(stream, start, stop string, count int64) *XMessageSliceCmd
func (c *ClusterClient) XRead(a *XReadArgs) *XStreamSliceCmd
func (c *ClusterClient) XReadGroup(a *XReadGroupArgs) *XStreamSliceCmd
func (c *ClusterClient) XReadStreams(streams ...string) *XStreamSliceCmd
func (c *ClusterClient) XRevRange(stream, start, stop string) *XMessageSliceCmd
func (c *ClusterClient) XRevRangeN(stream, start, stop string, count int64) *XMessageSliceCmd
func (c *ClusterClient) XTrim(key string, maxLen int64) *IntCmd
func (c *ClusterClient) XTrimApprox(key string, maxLen int64) *IntCmd
func (c *ClusterClient) ZAdd(key string, members ...Z) *IntCmd
Redis `ZADD key score member [score member ...]` command.
func (c *ClusterClient) ZAddCh(key string, members ...Z) *IntCmd
Redis `ZADD key CH score member [score member ...]` command.
func (c *ClusterClient) ZAddNX(key string, members ...Z) *IntCmd
Redis `ZADD key NX score member [score member ...]` command.
func (c *ClusterClient) ZAddNXCh(key string, members ...Z) *IntCmd
Redis `ZADD key NX CH score member [score member ...]` command.
func (c *ClusterClient) ZAddXX(key string, members ...Z) *IntCmd
Redis `ZADD key XX score member [score member ...]` command.
func (c *ClusterClient) ZAddXXCh(key string, members ...Z) *IntCmd
Redis `ZADD key XX CH score member [score member ...]` command.
func (c *ClusterClient) ZCard(key string) *IntCmd
func (c *ClusterClient) ZCount(key, min, max string) *IntCmd
func (c *ClusterClient) ZIncr(key string, member Z) *FloatCmd
Redis `ZADD key INCR score member` command.
func (c *ClusterClient) ZIncrBy(key string, increment float64, member string) *FloatCmd
func (c *ClusterClient) ZIncrNX(key string, member Z) *FloatCmd
Redis `ZADD key NX INCR score member` command.
func (c *ClusterClient) ZIncrXX(key string, member Z) *FloatCmd
Redis `ZADD key XX INCR score member` command.
func (c *ClusterClient) ZInterStore(destination string, store ZStore, keys ...string) *IntCmd
func (c *ClusterClient) ZLexCount(key, min, max string) *IntCmd
func (c *ClusterClient) ZPopMax(key string, count ...int64) *ZSliceCmd
func (c *ClusterClient) ZPopMin(key string, count ...int64) *ZSliceCmd
func (c *ClusterClient) ZRange(key string, start, stop int64) *StringSliceCmd
func (c *ClusterClient) ZRangeByLex(key string, opt ZRangeBy) *StringSliceCmd
func (c *ClusterClient) ZRangeByScore(key string, opt ZRangeBy) *StringSliceCmd
func (c *ClusterClient) ZRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd
func (c *ClusterClient) ZRangeWithScores(key string, start, stop int64) *ZSliceCmd
func (c *ClusterClient) ZRank(key, member string) *IntCmd
func (c *ClusterClient) ZRem(key string, members ...interface{}) *IntCmd
func (c *ClusterClient) ZRemRangeByLex(key, min, max string) *IntCmd
func (c *ClusterClient) ZRemRangeByRank(key string, start, stop int64) *IntCmd
func (c *ClusterClient) ZRemRangeByScore(key, min, max string) *IntCmd
func (c *ClusterClient) ZRevRange(key string, start, stop int64) *StringSliceCmd
func (c *ClusterClient) ZRevRangeByLex(key string, opt ZRangeBy) *StringSliceCmd
func (c *ClusterClient) ZRevRangeByScore(key string, opt ZRangeBy) *StringSliceCmd
func (c *ClusterClient) ZRevRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd
func (c *ClusterClient) ZRevRangeWithScores(key string, start, stop int64) *ZSliceCmd
func (c *ClusterClient) ZRevRank(key, member string) *IntCmd
func (c *ClusterClient) ZScan(key string, cursor uint64, match string, count int64) *ScanCmd
func (c *ClusterClient) ZScore(key, member string) *FloatCmd
func (c *ClusterClient) ZUnionStore(dest string, store ZStore, keys ...string) *IntCmd
type ClusterNode struct { Id string Addr string }
ClusterOptions are used to configure a cluster client and should be passed to NewClusterClient.
type ClusterOptions struct { // A seed list of host:port addresses of cluster nodes. Addrs []string // The maximum number of retries before giving up. Command is retried // on network errors and MOVED/ASK redirects. // Default is 8 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() ([]ClusterSlot, error) // Optional hook that is called when a new node is created. OnNewNode func(*Client) OnConnect func(*Conn) error 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 }
type ClusterSlot struct { Start int End int Nodes []ClusterNode }
type ClusterSlotsCmd struct {
// contains filtered or unexported fields
}
func NewClusterSlotsCmd(args ...interface{}) *ClusterSlotsCmd
func NewClusterSlotsCmdResult(val []ClusterSlot, err error) *ClusterSlotsCmd
NewClusterSlotsCmdResult returns a ClusterSlotsCmd initialised with val and err for testing
func (cmd *ClusterSlotsCmd) Args() []interface{}
func (cmd *ClusterSlotsCmd) Err() error
func (cmd *ClusterSlotsCmd) Name() string
func (cmd *ClusterSlotsCmd) Result() ([]ClusterSlot, error)
func (cmd *ClusterSlotsCmd) String() string
func (cmd *ClusterSlotsCmd) Val() []ClusterSlot
type Cmd struct {
// contains filtered or unexported fields
}
func NewCmd(args ...interface{}) *Cmd
func NewCmdResult(val interface{}, err error) *Cmd
NewCmdResult returns a Cmd initialised with val and err for testing
func (cmd *Cmd) Args() []interface{}
func (cmd *Cmd) Bool() (bool, error)
func (cmd *Cmd) Err() error
func (cmd *Cmd) Float32() (float32, error)
func (cmd *Cmd) Float64() (float64, error)
func (cmd *Cmd) Int() (int, error)
func (cmd *Cmd) Int64() (int64, error)
func (cmd *Cmd) Name() string
func (cmd *Cmd) Result() (interface{}, error)
func (cmd *Cmd) String() (string, error)
func (cmd *Cmd) Uint64() (uint64, error)
func (cmd *Cmd) Val() interface{}
type Cmdable interface { Pipeline() Pipeliner Pipelined(fn func(Pipeliner) error) ([]Cmder, error) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error) TxPipeline() Pipeliner Command() *CommandsInfoCmd ClientGetName() *StringCmd Echo(message interface{}) *StringCmd Ping() *StatusCmd Quit() *StatusCmd Del(keys ...string) *IntCmd Unlink(keys ...string) *IntCmd Dump(key string) *StringCmd Exists(keys ...string) *IntCmd Expire(key string, expiration time.Duration) *BoolCmd ExpireAt(key string, tm time.Time) *BoolCmd Keys(pattern string) *StringSliceCmd Migrate(host, port, key string, db int64, timeout time.Duration) *StatusCmd Move(key string, db int64) *BoolCmd ObjectRefCount(key string) *IntCmd ObjectEncoding(key string) *StringCmd ObjectIdleTime(key string) *DurationCmd Persist(key string) *BoolCmd PExpire(key string, expiration time.Duration) *BoolCmd PExpireAt(key string, tm time.Time) *BoolCmd PTTL(key string) *DurationCmd RandomKey() *StringCmd Rename(key, newkey string) *StatusCmd RenameNX(key, newkey string) *BoolCmd Restore(key string, ttl time.Duration, value string) *StatusCmd RestoreReplace(key string, ttl time.Duration, value string) *StatusCmd Sort(key string, sort *Sort) *StringSliceCmd SortStore(key, store string, sort *Sort) *IntCmd SortInterfaces(key string, sort *Sort) *SliceCmd Touch(keys ...string) *IntCmd TTL(key string) *DurationCmd Type(key string) *StatusCmd Scan(cursor uint64, match string, count int64) *ScanCmd SScan(key string, cursor uint64, match string, count int64) *ScanCmd HScan(key string, cursor uint64, match string, count int64) *ScanCmd ZScan(key string, cursor uint64, match string, count int64) *ScanCmd Append(key, value string) *IntCmd BitCount(key string, bitCount *BitCount) *IntCmd BitOpAnd(destKey string, keys ...string) *IntCmd BitOpOr(destKey string, keys ...string) *IntCmd BitOpXor(destKey string, keys ...string) *IntCmd BitOpNot(destKey string, key string) *IntCmd BitPos(key string, bit int64, pos ...int64) *IntCmd Decr(key string) *IntCmd DecrBy(key string, decrement int64) *IntCmd Get(key string) *StringCmd GetBit(key string, offset int64) *IntCmd GetRange(key string, start, end int64) *StringCmd GetSet(key string, value interface{}) *StringCmd Incr(key string) *IntCmd IncrBy(key string, value int64) *IntCmd IncrByFloat(key string, value float64) *FloatCmd MGet(keys ...string) *SliceCmd MSet(pairs ...interface{}) *StatusCmd MSetNX(pairs ...interface{}) *BoolCmd Set(key string, value interface{}, expiration time.Duration) *StatusCmd SetBit(key string, offset int64, value int) *IntCmd SetNX(key string, value interface{}, expiration time.Duration) *BoolCmd SetXX(key string, value interface{}, expiration time.Duration) *BoolCmd SetRange(key string, offset int64, value string) *IntCmd StrLen(key string) *IntCmd HDel(key string, fields ...string) *IntCmd HExists(key, field string) *BoolCmd HGet(key, field string) *StringCmd HGetAll(key string) *StringStringMapCmd HIncrBy(key, field string, incr int64) *IntCmd HIncrByFloat(key, field string, incr float64) *FloatCmd HKeys(key string) *StringSliceCmd HLen(key string) *IntCmd HMGet(key string, fields ...string) *SliceCmd HMSet(key string, fields map[string]interface{}) *StatusCmd HSet(key, field string, value interface{}) *BoolCmd HSetNX(key, field string, value interface{}) *BoolCmd HVals(key string) *StringSliceCmd BLPop(timeout time.Duration, keys ...string) *StringSliceCmd BRPop(timeout time.Duration, keys ...string) *StringSliceCmd BRPopLPush(source, destination string, timeout time.Duration) *StringCmd LIndex(key string, index int64) *StringCmd LInsert(key, op string, pivot, value interface{}) *IntCmd LInsertBefore(key string, pivot, value interface{}) *IntCmd LInsertAfter(key string, pivot, value interface{}) *IntCmd LLen(key string) *IntCmd LPop(key string) *StringCmd LPush(key string, values ...interface{}) *IntCmd LPushX(key string, value interface{}) *IntCmd LRange(key string, start, stop int64) *StringSliceCmd LRem(key string, count int64, value interface{}) *IntCmd LSet(key string, index int64, value interface{}) *StatusCmd LTrim(key string, start, stop int64) *StatusCmd RPop(key string) *StringCmd RPopLPush(source, destination string) *StringCmd RPush(key string, values ...interface{}) *IntCmd RPushX(key string, value interface{}) *IntCmd SAdd(key string, members ...interface{}) *IntCmd SCard(key string) *IntCmd SDiff(keys ...string) *StringSliceCmd SDiffStore(destination string, keys ...string) *IntCmd SInter(keys ...string) *StringSliceCmd SInterStore(destination string, keys ...string) *IntCmd SIsMember(key string, member interface{}) *BoolCmd SMembers(key string) *StringSliceCmd SMembersMap(key string) *StringStructMapCmd SMove(source, destination string, member interface{}) *BoolCmd SPop(key string) *StringCmd SPopN(key string, count int64) *StringSliceCmd SRandMember(key string) *StringCmd SRandMemberN(key string, count int64) *StringSliceCmd SRem(key string, members ...interface{}) *IntCmd SUnion(keys ...string) *StringSliceCmd SUnionStore(destination string, keys ...string) *IntCmd XAdd(a *XAddArgs) *StringCmd XDel(stream string, ids ...string) *IntCmd XLen(stream string) *IntCmd XRange(stream, start, stop string) *XMessageSliceCmd XRangeN(stream, start, stop string, count int64) *XMessageSliceCmd XRevRange(stream string, start, stop string) *XMessageSliceCmd XRevRangeN(stream string, start, stop string, count int64) *XMessageSliceCmd XRead(a *XReadArgs) *XStreamSliceCmd XReadStreams(streams ...string) *XStreamSliceCmd XGroupCreate(stream, group, start string) *StatusCmd XGroupCreateMkStream(stream, group, start string) *StatusCmd XGroupSetID(stream, group, start string) *StatusCmd XGroupDestroy(stream, group string) *IntCmd XGroupDelConsumer(stream, group, consumer string) *IntCmd XReadGroup(a *XReadGroupArgs) *XStreamSliceCmd XAck(stream, group string, ids ...string) *IntCmd XPending(stream, group string) *XPendingCmd XPendingExt(a *XPendingExtArgs) *XPendingExtCmd XClaim(a *XClaimArgs) *XMessageSliceCmd XClaimJustID(a *XClaimArgs) *StringSliceCmd XTrim(key string, maxLen int64) *IntCmd XTrimApprox(key string, maxLen int64) *IntCmd BZPopMax(timeout time.Duration, keys ...string) *ZWithKeyCmd BZPopMin(timeout time.Duration, keys ...string) *ZWithKeyCmd ZAdd(key string, members ...Z) *IntCmd ZAddNX(key string, members ...Z) *IntCmd ZAddXX(key string, members ...Z) *IntCmd ZAddCh(key string, members ...Z) *IntCmd ZAddNXCh(key string, members ...Z) *IntCmd ZAddXXCh(key string, members ...Z) *IntCmd ZIncr(key string, member Z) *FloatCmd ZIncrNX(key string, member Z) *FloatCmd ZIncrXX(key string, member Z) *FloatCmd ZCard(key string) *IntCmd ZCount(key, min, max string) *IntCmd ZLexCount(key, min, max string) *IntCmd ZIncrBy(key string, increment float64, member string) *FloatCmd ZInterStore(destination string, store ZStore, keys ...string) *IntCmd ZPopMax(key string, count ...int64) *ZSliceCmd ZPopMin(key string, count ...int64) *ZSliceCmd ZRange(key string, start, stop int64) *StringSliceCmd ZRangeWithScores(key string, start, stop int64) *ZSliceCmd ZRangeByScore(key string, opt ZRangeBy) *StringSliceCmd ZRangeByLex(key string, opt ZRangeBy) *StringSliceCmd ZRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd ZRank(key, member string) *IntCmd ZRem(key string, members ...interface{}) *IntCmd ZRemRangeByRank(key string, start, stop int64) *IntCmd ZRemRangeByScore(key, min, max string) *IntCmd ZRemRangeByLex(key, min, max string) *IntCmd ZRevRange(key string, start, stop int64) *StringSliceCmd ZRevRangeWithScores(key string, start, stop int64) *ZSliceCmd ZRevRangeByScore(key string, opt ZRangeBy) *StringSliceCmd ZRevRangeByLex(key string, opt ZRangeBy) *StringSliceCmd ZRevRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd ZRevRank(key, member string) *IntCmd ZScore(key, member string) *FloatCmd ZUnionStore(dest string, store ZStore, keys ...string) *IntCmd PFAdd(key string, els ...interface{}) *IntCmd PFCount(keys ...string) *IntCmd PFMerge(dest string, keys ...string) *StatusCmd BgRewriteAOF() *StatusCmd BgSave() *StatusCmd ClientKill(ipPort string) *StatusCmd ClientKillByFilter(keys ...string) *IntCmd ClientList() *StringCmd ClientPause(dur time.Duration) *BoolCmd ClientID() *IntCmd ConfigGet(parameter string) *SliceCmd ConfigResetStat() *StatusCmd ConfigSet(parameter, value string) *StatusCmd ConfigRewrite() *StatusCmd DBSize() *IntCmd FlushAll() *StatusCmd FlushAllAsync() *StatusCmd FlushDB() *StatusCmd FlushDBAsync() *StatusCmd Info(section ...string) *StringCmd LastSave() *IntCmd Save() *StatusCmd Shutdown() *StatusCmd ShutdownSave() *StatusCmd ShutdownNoSave() *StatusCmd SlaveOf(host, port string) *StatusCmd Time() *TimeCmd Eval(script string, keys []string, args ...interface{}) *Cmd EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd ScriptExists(hashes ...string) *BoolSliceCmd ScriptFlush() *StatusCmd ScriptKill() *StatusCmd ScriptLoad(script string) *StringCmd DebugObject(key string) *StringCmd Publish(channel string, message interface{}) *IntCmd PubSubChannels(pattern string) *StringSliceCmd PubSubNumSub(channels ...string) *StringIntMapCmd PubSubNumPat() *IntCmd ClusterSlots() *ClusterSlotsCmd ClusterNodes() *StringCmd ClusterMeet(host, port string) *StatusCmd ClusterForget(nodeID string) *StatusCmd ClusterReplicate(nodeID string) *StatusCmd ClusterResetSoft() *StatusCmd ClusterResetHard() *StatusCmd ClusterInfo() *StringCmd ClusterKeySlot(key string) *IntCmd ClusterGetKeysInSlot(slot int, count int) *StringSliceCmd ClusterCountFailureReports(nodeID string) *IntCmd ClusterCountKeysInSlot(slot int) *IntCmd ClusterDelSlots(slots ...int) *StatusCmd ClusterDelSlotsRange(min, max int) *StatusCmd ClusterSaveConfig() *StatusCmd ClusterSlaves(nodeID string) *StringSliceCmd ClusterFailover() *StatusCmd ClusterAddSlots(slots ...int) *StatusCmd ClusterAddSlotsRange(min, max int) *StatusCmd GeoAdd(key string, geoLocation ...*GeoLocation) *IntCmd GeoPos(key string, members ...string) *GeoPosCmd GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd GeoRadiusRO(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd GeoRadiusByMember(key, member string, query *GeoRadiusQuery) *GeoLocationCmd GeoRadiusByMemberRO(key, member string, query *GeoRadiusQuery) *GeoLocationCmd GeoDist(key string, member1, member2, unit string) *FloatCmd GeoHash(key string, members ...string) *StringSliceCmd ReadOnly() *StatusCmd ReadWrite() *StatusCmd MemoryUsage(key string, samples ...int) *IntCmd }
type Cmder interface { Name() string Args() []interface{} Err() error // contains filtered or unexported methods }
type CommandInfo struct { Name string Arity int8 Flags []string FirstKeyPos int8 LastKeyPos int8 StepCount int8 ReadOnly bool }
type CommandsInfoCmd struct {
// contains filtered or unexported fields
}
func NewCommandsInfoCmd(args ...interface{}) *CommandsInfoCmd
func NewCommandsInfoCmdResult(val map[string]*CommandInfo, err error) *CommandsInfoCmd
NewCommandsInfoCmdResult returns a CommandsInfoCmd initialised with val and err for testing
func (cmd *CommandsInfoCmd) Args() []interface{}
func (cmd *CommandsInfoCmd) Err() error
func (cmd *CommandsInfoCmd) Name() string
func (cmd *CommandsInfoCmd) Result() (map[string]*CommandInfo, error)
func (cmd *CommandsInfoCmd) String() string
func (cmd *CommandsInfoCmd) Val() map[string]*CommandInfo
Conn is like Client, but its pool contains single connection.
type Conn struct {
// contains filtered or unexported fields
}
func (c *Conn) Auth(password string) *StatusCmd
func (c *Conn) ClientSetName(name string) *BoolCmd
ClientSetName assigns a name to the connection.
func (c *Conn) Close() error
Close closes the client, releasing any open resources.
It is rare to Close a Client, as the Client is meant to be long-lived and shared between many goroutines.
func (c *Conn) Do(args ...interface{}) *Cmd
Do creates a Cmd from the args and processes the cmd.
func (c *Conn) Pipeline() Pipeliner
func (c *Conn) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)
func (c *Conn) Process(cmd Cmder) error
func (c *Conn) Select(index int) *StatusCmd
func (c *Conn) String() string
func (c *Conn) SwapDB(index1, index2 int) *StatusCmd
func (c *Conn) TxPipeline() Pipeliner
TxPipeline acts like Pipeline, but wraps queued commands with MULTI/EXEC.
func (c *Conn) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error)
func (c *Conn) WrapProcess( fn func(oldProcess func(cmd Cmder) error) func(cmd Cmder) error, )
WrapProcess wraps function that processes Redis commands.
func (c *Conn) WrapProcessPipeline( fn func(oldProcess func([]Cmder) error) func([]Cmder) error, )
type DurationCmd struct {
// contains filtered or unexported fields
}
func NewDurationCmd(precision time.Duration, args ...interface{}) *DurationCmd
func NewDurationResult(val time.Duration, err error) *DurationCmd
NewDurationResult returns a DurationCmd initialised with val and err for testing
func (cmd *DurationCmd) Args() []interface{}
func (cmd *DurationCmd) Err() error
func (cmd *DurationCmd) Name() string
func (cmd *DurationCmd) Result() (time.Duration, error)
func (cmd *DurationCmd) String() string
func (cmd *DurationCmd) Val() time.Duration
FailoverOptions are used to configure a failover client and should be passed to NewFailoverClient.
type FailoverOptions struct { // The master name. MasterName string // A seed list of host:port addresses of sentinel nodes. SentinelAddrs []string OnConnect func(*Conn) error Password string DB int MaxRetries int 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 }
type FloatCmd struct {
// contains filtered or unexported fields
}
func NewFloatCmd(args ...interface{}) *FloatCmd
func NewFloatResult(val float64, err error) *FloatCmd
NewFloatResult returns a FloatCmd initialised with val and err for testing
func (cmd *FloatCmd) Args() []interface{}
func (cmd *FloatCmd) Err() error
func (cmd *FloatCmd) Name() string
func (cmd *FloatCmd) Result() (float64, error)
func (cmd *FloatCmd) String() string
func (cmd *FloatCmd) Val() float64
GeoLocation is used with GeoAdd to add geospatial location.
type GeoLocation struct { Name string Longitude, Latitude, Dist float64 GeoHash int64 }
type GeoLocationCmd struct {
// contains filtered or unexported fields
}
func NewGeoLocationCmd(q *GeoRadiusQuery, args ...interface{}) *GeoLocationCmd
func NewGeoLocationCmdResult(val []GeoLocation, err error) *GeoLocationCmd
NewGeoLocationCmdResult returns a GeoLocationCmd initialised with val and err for testing
func (cmd *GeoLocationCmd) Args() []interface{}
func (cmd *GeoLocationCmd) Err() error
func (cmd *GeoLocationCmd) Name() string
func (cmd *GeoLocationCmd) Result() ([]GeoLocation, error)
func (cmd *GeoLocationCmd) String() string
func (cmd *GeoLocationCmd) Val() []GeoLocation
type GeoPos struct { Longitude, Latitude float64 }
type GeoPosCmd struct {
// contains filtered or unexported fields
}
func NewGeoPosCmd(args ...interface{}) *GeoPosCmd
func (cmd *GeoPosCmd) Args() []interface{}
func (cmd *GeoPosCmd) Err() error
func (cmd *GeoPosCmd) Name() string
func (cmd *GeoPosCmd) Result() ([]*GeoPos, error)
func (cmd *GeoPosCmd) String() string
func (cmd *GeoPosCmd) Val() []*GeoPos
GeoRadiusQuery is used with GeoRadius to query geospatial index.
type GeoRadiusQuery struct { Radius float64 // Can be m, km, ft, or mi. Default is km. Unit string WithCoord bool WithDist bool WithGeoHash bool Count int // Can be ASC or DESC. Default is no sort order. Sort string Store string StoreDist string }
Hash is type of hash function used in consistent hash.
type Hash consistenthash.Hash
type IntCmd struct {
// contains filtered or unexported fields
}
func NewIntCmd(args ...interface{}) *IntCmd
func NewIntResult(val int64, err error) *IntCmd
NewIntResult returns an IntCmd initialised with val and err for testing
func (cmd *IntCmd) Args() []interface{}
func (cmd *IntCmd) Err() error
func (cmd *IntCmd) Name() string
func (cmd *IntCmd) Result() (int64, error)
func (cmd *IntCmd) String() string
func (cmd *IntCmd) Val() int64
Limiter is the interface of a rate limiter or a circuit breaker.
type Limiter interface { // Allow returns a nil if operation is allowed or an error otherwise. // If operation is allowed client must report the result of operation // whether is a success or a failure. Allow() error // ReportResult reports the result of previously allowed operation. // nil indicates a success, non-nil error indicates a failure. ReportResult(result error) }
Message received as result of a PUBLISH command issued by another client.
type Message struct { Channel string Pattern string Payload string }
func (m *Message) String() string
type Options struct { // The network type, either tcp or unix. // Default is tcp. Network string // host:port address. Addr string // Dialer creates new network connection and has priority over // Network and Addr options. Dialer func() (net.Conn, error) // Hook that is called when new connection is established. OnConnect func(*Conn) error // Optional password. Must match the password specified in the // requirepass server configuration option. Password string // Database to be selected after connecting to the server. DB int // Maximum number of retries before giving up. // Default is to not retry failed commands. MaxRetries int // 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 // contains filtered or unexported fields }
func ParseURL(redisURL string) (*Options, error)
ParseURL parses an URL into Options that can be used to connect to Redis.
▹ Example
Pipeline implements pipelining as described in http://redis.io/topics/pipelining. It's safe for concurrent use by multiple goroutines.
type Pipeline struct {
// contains filtered or unexported fields
}
▹ Example (Instrumentation)
func (c *Pipeline) Auth(password string) *StatusCmd
func (c *Pipeline) ClientSetName(name string) *BoolCmd
ClientSetName assigns a name to the connection.
func (c *Pipeline) Close() error
Close closes the pipeline, releasing any open resources.
func (c *Pipeline) Discard() error
Discard resets the pipeline and discards queued commands.
func (c *Pipeline) Do(args ...interface{}) *Cmd
func (c *Pipeline) Exec() ([]Cmder, error)
Exec executes all previously queued commands using one client-server roundtrip.
Exec always returns list of commands and error of the first failed command if any.
func (c *Pipeline) Pipeline() Pipeliner
func (c *Pipeline) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)
func (c *Pipeline) Process(cmd Cmder) error
Process queues the cmd for later execution.
func (c *Pipeline) Select(index int) *StatusCmd
func (c *Pipeline) SwapDB(index1, index2 int) *StatusCmd
func (c *Pipeline) TxPipeline() Pipeliner
func (c *Pipeline) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error)
Pipeliner is an mechanism to realise Redis Pipeline technique.
Pipelining is a technique to extremely speed up processing by packing operations to batches, send them at once to Redis and read a replies in a singe step. See https://redis.io/topics/pipelining
Pay attention, that Pipeline is not a transaction, so you can get unexpected results in case of big pipelines and small read/write timeouts. Redis client has retransmission logic in case of timeouts, pipeline can be retransmitted and commands can be executed more then once. To avoid this: it is good idea to use reasonable bigger read/write timeouts depends of your batch size and/or use TxPipeline.
type Pipeliner interface { StatefulCmdable Do(args ...interface{}) *Cmd Process(cmd Cmder) error Close() error Discard() error Exec() ([]Cmder, error) }
Pong received as result of a PING command issued by another client.
type Pong struct { Payload string }
func (p *Pong) String() string
type PoolStats pool.Stats
PubSub implements Pub/Sub commands as described in http://redis.io/topics/pubsub. Message receiving is NOT safe for concurrent use by multiple goroutines.
PubSub automatically reconnects to Redis Server and resubscribes to the channels in case of network errors.
type PubSub struct {
// contains filtered or unexported fields
}
▹ Example
func (c *PubSub) Channel() <-chan *Message
Channel returns a Go channel for concurrently receiving messages. It periodically sends Ping messages to test connection health. The channel is closed with PubSub. Receive* APIs can not be used after channel is created.
If the Go channel is full for 30 seconds the message is dropped.
func (c *PubSub) ChannelSize(size int) <-chan *Message
ChannelSize is like Channel, but creates a Go channel with specified buffer size.
func (c *PubSub) Close() error
func (c *PubSub) PSubscribe(patterns ...string) error
PSubscribe the client to the given patterns. It returns empty subscription if there are no patterns.
func (c *PubSub) PUnsubscribe(patterns ...string) error
PUnsubscribe the client from the given patterns, or from all of them if none is given.
func (c *PubSub) Ping(payload ...string) error
func (c *PubSub) Receive() (interface{}, error)
Receive returns a message as a Subscription, Message, Pong or error. See PubSub example for details. This is low-level API and in most cases Channel should be used instead.
▹ Example
func (c *PubSub) ReceiveMessage() (*Message, error)
ReceiveMessage returns a Message or error ignoring Subscription and Pong messages. This is low-level API and in most cases Channel should be used instead.
func (c *PubSub) ReceiveTimeout(timeout time.Duration) (interface{}, error)
ReceiveTimeout acts like Receive but returns an error if message is not received in time. This is low-level API and in most cases Channel should be used instead.
func (c *PubSub) String() string
func (c *PubSub) Subscribe(channels ...string) error
Subscribe the client to the specified channels. It returns empty subscription if there are no channels.
func (c *PubSub) Unsubscribe(channels ...string) error
Unsubscribe the client from the given channels, or from all of them if none is given.
Ring is a Redis client that uses consistent hashing to distribute keys across multiple Redis servers (shards). It's safe for concurrent use by multiple goroutines.
Ring monitors the state of each shard and removes dead shards from the ring. When a shard comes online it is added back to the ring. This gives you maximum availability and partition tolerance, but no consistency between different shards or even clients. Each client uses shards that are available to the client and does not do any coordination when shard state is changed.
Ring should be used when you need multiple Redis servers for caching and can tolerate losing data when one of the servers dies. Otherwise you should use Redis Cluster.
type Ring struct {
// contains filtered or unexported fields
}
func NewRing(opt *RingOptions) *Ring
▹ Example
func (c *Ring) Append(key, value string) *IntCmd
func (c *Ring) BLPop(timeout time.Duration, keys ...string) *StringSliceCmd
func (c *Ring) BRPop(timeout time.Duration, keys ...string) *StringSliceCmd
func (c *Ring) BRPopLPush(source, destination string, timeout time.Duration) *StringCmd
func (c *Ring) BZPopMax(timeout time.Duration, keys ...string) *ZWithKeyCmd
Redis `BZPOPMAX key [key ...] timeout` command.
func (c *Ring) BZPopMin(timeout time.Duration, keys ...string) *ZWithKeyCmd
Redis `BZPOPMIN key [key ...] timeout` command.
func (c *Ring) BgRewriteAOF() *StatusCmd
func (c *Ring) BgSave() *StatusCmd
func (c *Ring) BitCount(key string, bitCount *BitCount) *IntCmd
func (c *Ring) BitOpAnd(destKey string, keys ...string) *IntCmd
func (c *Ring) BitOpNot(destKey string, key string) *IntCmd
func (c *Ring) BitOpOr(destKey string, keys ...string) *IntCmd
func (c *Ring) BitOpXor(destKey string, keys ...string) *IntCmd
func (c *Ring) BitPos(key string, bit int64, pos ...int64) *IntCmd
func (c *Ring) ClientGetName() *StringCmd
ClientGetName returns the name of the connection.
func (c *Ring) ClientID() *IntCmd
func (c *Ring) ClientKill(ipPort string) *StatusCmd
func (c *Ring) ClientKillByFilter(keys ...string) *IntCmd
ClientKillByFilter is new style synx, while the ClientKill is old CLIENT KILL <option> [value] ... <option> [value]
func (c *Ring) ClientList() *StringCmd
func (c *Ring) ClientPause(dur time.Duration) *BoolCmd
func (c *Ring) ClientUnblock(id int64) *IntCmd
func (c *Ring) ClientUnblockWithError(id int64) *IntCmd
func (c *Ring) Close() error
Close closes the ring client, releasing any open resources.
It is rare to Close a Ring, as the Ring is meant to be long-lived and shared between many goroutines.
func (c *Ring) ClusterAddSlots(slots ...int) *StatusCmd
func (c *Ring) ClusterAddSlotsRange(min, max int) *StatusCmd
func (c *Ring) ClusterCountFailureReports(nodeID string) *IntCmd
func (c *Ring) ClusterCountKeysInSlot(slot int) *IntCmd
func (c *Ring) ClusterDelSlots(slots ...int) *StatusCmd
func (c *Ring) ClusterDelSlotsRange(min, max int) *StatusCmd
func (c *Ring) ClusterFailover() *StatusCmd
func (c *Ring) ClusterForget(nodeID string) *StatusCmd
func (c *Ring) ClusterGetKeysInSlot(slot int, count int) *StringSliceCmd
func (c *Ring) ClusterInfo() *StringCmd
func (c *Ring) ClusterKeySlot(key string) *IntCmd
func (c *Ring) ClusterMeet(host, port string) *StatusCmd
func (c *Ring) ClusterNodes() *StringCmd
func (c *Ring) ClusterReplicate(nodeID string) *StatusCmd
func (c *Ring) ClusterResetHard() *StatusCmd
func (c *Ring) ClusterResetSoft() *StatusCmd
func (c *Ring) ClusterSaveConfig() *StatusCmd
func (c *Ring) ClusterSlaves(nodeID string) *StringSliceCmd
func (c *Ring) ClusterSlots() *ClusterSlotsCmd
func (c *Ring) Command() *CommandsInfoCmd
func (c *Ring) ConfigGet(parameter string) *SliceCmd
func (c *Ring) ConfigResetStat() *StatusCmd
func (c *Ring) ConfigRewrite() *StatusCmd
func (c *Ring) ConfigSet(parameter, value string) *StatusCmd
func (c *Ring) Context() context.Context
func (c *Ring) DBSize() *IntCmd
func (c *Ring) DbSize() *IntCmd
Deperecated. Use DBSize instead.
func (c *Ring) DebugObject(key string) *StringCmd
func (c *Ring) Decr(key string) *IntCmd
func (c *Ring) DecrBy(key string, decrement int64) *IntCmd
func (c *Ring) Del(keys ...string) *IntCmd
func (c *Ring) Do(args ...interface{}) *Cmd
Do creates a Cmd from the args and processes the cmd.
func (c *Ring) Dump(key string) *StringCmd
func (c *Ring) Echo(message interface{}) *StringCmd
func (c *Ring) Eval(script string, keys []string, args ...interface{}) *Cmd
func (c *Ring) EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd
func (c *Ring) Exists(keys ...string) *IntCmd
func (c *Ring) Expire(key string, expiration time.Duration) *BoolCmd
func (c *Ring) ExpireAt(key string, tm time.Time) *BoolCmd
func (c *Ring) FlushAll() *StatusCmd
func (c *Ring) FlushAllAsync() *StatusCmd
func (c *Ring) FlushDB() *StatusCmd
func (c *Ring) FlushDBAsync() *StatusCmd
func (c *Ring) FlushDb() *StatusCmd
Deprecated. Use FlushDB instead.
func (c *Ring) ForEachShard(fn func(client *Client) error) error
ForEachShard concurrently calls the fn on each live shard in the ring. It returns the first error if any.
func (c *Ring) GeoAdd(key string, geoLocation ...*GeoLocation) *IntCmd
func (c *Ring) GeoDist(key string, member1, member2, unit string) *FloatCmd
func (c *Ring) GeoHash(key string, members ...string) *StringSliceCmd
func (c *Ring) GeoPos(key string, members ...string) *GeoPosCmd
func (c *Ring) GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd
func (c *Ring) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) *GeoLocationCmd
func (c *Ring) GeoRadiusByMemberRO(key, member string, query *GeoRadiusQuery) *GeoLocationCmd
func (c *Ring) GeoRadiusRO(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd
func (c *Ring) Get(key string) *StringCmd
Redis `GET key` command. It returns redis.Nil error when key does not exist.
func (c *Ring) GetBit(key string, offset int64) *IntCmd
func (c *Ring) GetRange(key string, start, end int64) *StringCmd
func (c *Ring) GetSet(key string, value interface{}) *StringCmd
func (c *Ring) HDel(key string, fields ...string) *IntCmd
func (c *Ring) HExists(key, field string) *BoolCmd
func (c *Ring) HGet(key, field string) *StringCmd
func (c *Ring) HGetAll(key string) *StringStringMapCmd
func (c *Ring) HIncrBy(key, field string, incr int64) *IntCmd
func (c *Ring) HIncrByFloat(key, field string, incr float64) *FloatCmd
func (c *Ring) HKeys(key string) *StringSliceCmd
func (c *Ring) HLen(key string) *IntCmd
func (c *Ring) HMGet(key string, fields ...string) *SliceCmd
func (c *Ring) HMSet(key string, fields map[string]interface{}) *StatusCmd
func (c *Ring) HScan(key string, cursor uint64, match string, count int64) *ScanCmd
func (c *Ring) HSet(key, field string, value interface{}) *BoolCmd
func (c *Ring) HSetNX(key, field string, value interface{}) *BoolCmd
func (c *Ring) HVals(key string) *StringSliceCmd
func (c *Ring) Incr(key string) *IntCmd
func (c *Ring) IncrBy(key string, value int64) *IntCmd
func (c *Ring) IncrByFloat(key string, value float64) *FloatCmd
func (c *Ring) Info(section ...string) *StringCmd
func (c *Ring) Keys(pattern string) *StringSliceCmd
func (c *Ring) LIndex(key string, index int64) *StringCmd
func (c *Ring) LInsert(key, op string, pivot, value interface{}) *IntCmd
func (c *Ring) LInsertAfter(key string, pivot, value interface{}) *IntCmd
func (c *Ring) LInsertBefore(key string, pivot, value interface{}) *IntCmd
func (c *Ring) LLen(key string) *IntCmd
func (c *Ring) LPop(key string) *StringCmd
func (c *Ring) LPush(key string, values ...interface{}) *IntCmd
func (c *Ring) LPushX(key string, value interface{}) *IntCmd
func (c *Ring) LRange(key string, start, stop int64) *StringSliceCmd
func (c *Ring) LRem(key string, count int64, value interface{}) *IntCmd
func (c *Ring) LSet(key string, index int64, value interface{}) *StatusCmd
func (c *Ring) LTrim(key string, start, stop int64) *StatusCmd
func (c *Ring) LastSave() *IntCmd
func (c *Ring) Len() int
Len returns the current number of shards in the ring.
func (c *Ring) MGet(keys ...string) *SliceCmd
func (c *Ring) MSet(pairs ...interface{}) *StatusCmd
func (c *Ring) MSetNX(pairs ...interface{}) *BoolCmd
func (c *Ring) MemoryUsage(key string, samples ...int) *IntCmd
func (c *Ring) Migrate(host, port, key string, db int64, timeout time.Duration) *StatusCmd
func (c *Ring) Move(key string, db int64) *BoolCmd
func (c *Ring) ObjectEncoding(key string) *StringCmd
func (c *Ring) ObjectIdleTime(key string) *DurationCmd
func (c *Ring) ObjectRefCount(key string) *IntCmd
func (c *Ring) Options() *RingOptions
Options returns read-only Options that were used to create the client.
func (c *Ring) PExpire(key string, expiration time.Duration) *BoolCmd
func (c *Ring) PExpireAt(key string, tm time.Time) *BoolCmd
func (c *Ring) PFAdd(key string, els ...interface{}) *IntCmd
func (c *Ring) PFCount(keys ...string) *IntCmd
func (c *Ring) PFMerge(dest string, keys ...string) *StatusCmd
func (c *Ring) PSubscribe(channels ...string) *PubSub
PSubscribe subscribes the client to the given patterns.
func (c *Ring) PTTL(key string) *DurationCmd
func (c *Ring) Persist(key string) *BoolCmd
func (c *Ring) Ping() *StatusCmd
func (c *Ring) Pipeline() Pipeliner
func (c *Ring) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)
func (c *Ring) PoolStats() *PoolStats
PoolStats returns accumulated connection pool stats.
func (c *Ring) Process(cmd Cmder) error
func (c *Ring) PubSubChannels(pattern string) *StringSliceCmd
func (c *Ring) PubSubNumPat() *IntCmd
func (c *Ring) PubSubNumSub(channels ...string) *StringIntMapCmd
func (c *Ring) Publish(channel string, message interface{}) *IntCmd
Publish posts the message to the channel.
func (c *Ring) Quit() *StatusCmd
func (c *Ring) RPop(key string) *StringCmd
func (c *Ring) RPopLPush(source, destination string) *StringCmd
func (c *Ring) RPush(key string, values ...interface{}) *IntCmd
func (c *Ring) RPushX(key string, value interface{}) *IntCmd
func (c *Ring) RandomKey() *StringCmd
func (c *Ring) ReadOnly() *StatusCmd
func (c *Ring) ReadWrite() *StatusCmd
func (c *Ring) Rename(key, newkey string) *StatusCmd
func (c *Ring) RenameNX(key, newkey string) *BoolCmd
func (c *Ring) Restore(key string, ttl time.Duration, value string) *StatusCmd
func (c *Ring) RestoreReplace(key string, ttl time.Duration, value string) *StatusCmd
func (c *Ring) SAdd(key string, members ...interface{}) *IntCmd
func (c *Ring) SCard(key string) *IntCmd
func (c *Ring) SDiff(keys ...string) *StringSliceCmd
func (c *Ring) SDiffStore(destination string, keys ...string) *IntCmd
func (c *Ring) SInter(keys ...string) *StringSliceCmd
func (c *Ring) SInterStore(destination string, keys ...string) *IntCmd
func (c *Ring) SIsMember(key string, member interface{}) *BoolCmd
func (c *Ring) SMembers(key string) *StringSliceCmd
Redis `SMEMBERS key` command output as a slice
func (c *Ring) SMembersMap(key string) *StringStructMapCmd
Redis `SMEMBERS key` command output as a map
func (c *Ring) SMove(source, destination string, member interface{}) *BoolCmd
func (c *Ring) SPop(key string) *StringCmd
Redis `SPOP key` command.
func (c *Ring) SPopN(key string, count int64) *StringSliceCmd
Redis `SPOP key count` command.
func (c *Ring) SRandMember(key string) *StringCmd
Redis `SRANDMEMBER key` command.
func (c *Ring) SRandMemberN(key string, count int64) *StringSliceCmd
Redis `SRANDMEMBER key count` command.
func (c *Ring) SRem(key string, members ...interface{}) *IntCmd
func (c *Ring) SScan(key string, cursor uint64, match string, count int64) *ScanCmd
func (c *Ring) SUnion(keys ...string) *StringSliceCmd
func (c *Ring) SUnionStore(destination string, keys ...string) *IntCmd
func (c *Ring) Save() *StatusCmd
func (c *Ring) Scan(cursor uint64, match string, count int64) *ScanCmd
func (c *Ring) ScriptExists(hashes ...string) *BoolSliceCmd
func (c *Ring) ScriptFlush() *StatusCmd
func (c *Ring) ScriptKill() *StatusCmd
func (c *Ring) ScriptLoad(script string) *StringCmd
func (c *Ring) Set(key string, value interface{}, expiration time.Duration) *StatusCmd
Redis `SET key value [expiration]` command.
Use expiration for `SETEX`-like behavior. Zero expiration means the key has no expiration time.
func (c *Ring) SetBit(key string, offset int64, value int) *IntCmd
func (c *Ring) SetNX(key string, value interface{}, expiration time.Duration) *BoolCmd
Redis `SET key value [expiration] NX` command.
Zero expiration means the key has no expiration time.
func (c *Ring) SetRange(key string, offset int64, value string) *IntCmd
func (c *Ring) SetXX(key string, value interface{}, expiration time.Duration) *BoolCmd
Redis `SET key value [expiration] XX` command.
Zero expiration means the key has no expiration time.
func (c *Ring) Shutdown() *StatusCmd
func (c *Ring) ShutdownNoSave() *StatusCmd
func (c *Ring) ShutdownSave() *StatusCmd
func (c *Ring) SlaveOf(host, port string) *StatusCmd
func (c *Ring) SlowLog()
func (c *Ring) Sort(key string, sort *Sort) *StringSliceCmd
func (c *Ring) SortInterfaces(key string, sort *Sort) *SliceCmd
func (c *Ring) SortStore(key, store string, sort *Sort) *IntCmd
func (c *Ring) StrLen(key string) *IntCmd
func (c *Ring) Subscribe(channels ...string) *PubSub
Subscribe subscribes the client to the specified channels.
func (c *Ring) Sync()
func (c *Ring) TTL(key string) *DurationCmd
func (c *Ring) Time() *TimeCmd
func (c *Ring) Touch(keys ...string) *IntCmd
func (c *Ring) TxPipeline() Pipeliner
func (c *Ring) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error)
func (c *Ring) Type(key string) *StatusCmd
func (c *Ring) Unlink(keys ...string) *IntCmd
func (c *Ring) Wait(numSlaves int, timeout time.Duration) *IntCmd
func (c *Ring) Watch(fn func(*Tx) error, keys ...string) error
func (c *Ring) WithContext(ctx context.Context) *Ring
func (c *Ring) WrapProcess( fn func(oldProcess func(cmd Cmder) error) func(cmd Cmder) error, )
func (c *Ring) WrapProcessPipeline( fn func(oldProcess func([]Cmder) error) func([]Cmder) error, )
func (c *Ring) XAck(stream, group string, ids ...string) *IntCmd
func (c *Ring) XAdd(a *XAddArgs) *StringCmd
func (c *Ring) XClaim(a *XClaimArgs) *XMessageSliceCmd
func (c *Ring) XClaimJustID(a *XClaimArgs) *StringSliceCmd
func (c *Ring) XDel(stream string, ids ...string) *IntCmd
func (c *Ring) XGroupCreate(stream, group, start string) *StatusCmd
func (c *Ring) XGroupCreateMkStream(stream, group, start string) *StatusCmd
func (c *Ring) XGroupDelConsumer(stream, group, consumer string) *IntCmd
func (c *Ring) XGroupDestroy(stream, group string) *IntCmd
func (c *Ring) XGroupSetID(stream, group, start string) *StatusCmd
func (c *Ring) XLen(stream string) *IntCmd
func (c *Ring) XPending(stream, group string) *XPendingCmd
func (c *Ring) XPendingExt(a *XPendingExtArgs) *XPendingExtCmd
func (c *Ring) XRange(stream, start, stop string) *XMessageSliceCmd
func (c *Ring) XRangeN(stream, start, stop string, count int64) *XMessageSliceCmd
func (c *Ring) XRead(a *XReadArgs) *XStreamSliceCmd
func (c *Ring) XReadGroup(a *XReadGroupArgs) *XStreamSliceCmd
func (c *Ring) XReadStreams(streams ...string) *XStreamSliceCmd
func (c *Ring) XRevRange(stream, start, stop string) *XMessageSliceCmd
func (c *Ring) XRevRangeN(stream, start, stop string, count int64) *XMessageSliceCmd
func (c *Ring) XTrim(key string, maxLen int64) *IntCmd
func (c *Ring) XTrimApprox(key string, maxLen int64) *IntCmd
func (c *Ring) ZAdd(key string, members ...Z) *IntCmd
Redis `ZADD key score member [score member ...]` command.
func (c *Ring) ZAddCh(key string, members ...Z) *IntCmd
Redis `ZADD key CH score member [score member ...]` command.
func (c *Ring) ZAddNX(key string, members ...Z) *IntCmd
Redis `ZADD key NX score member [score member ...]` command.
func (c *Ring) ZAddNXCh(key string, members ...Z) *IntCmd
Redis `ZADD key NX CH score member [score member ...]` command.
func (c *Ring) ZAddXX(key string, members ...Z) *IntCmd
Redis `ZADD key XX score member [score member ...]` command.
func (c *Ring) ZAddXXCh(key string, members ...Z) *IntCmd
Redis `ZADD key XX CH score member [score member ...]` command.
func (c *Ring) ZCard(key string) *IntCmd
func (c *Ring) ZCount(key, min, max string) *IntCmd
func (c *Ring) ZIncr(key string, member Z) *FloatCmd
Redis `ZADD key INCR score member` command.
func (c *Ring) ZIncrBy(key string, increment float64, member string) *FloatCmd
func (c *Ring) ZIncrNX(key string, member Z) *FloatCmd
Redis `ZADD key NX INCR score member` command.
func (c *Ring) ZIncrXX(key string, member Z) *FloatCmd
Redis `ZADD key XX INCR score member` command.
func (c *Ring) ZInterStore(destination string, store ZStore, keys ...string) *IntCmd
func (c *Ring) ZLexCount(key, min, max string) *IntCmd
func (c *Ring) ZPopMax(key string, count ...int64) *ZSliceCmd
func (c *Ring) ZPopMin(key string, count ...int64) *ZSliceCmd
func (c *Ring) ZRange(key string, start, stop int64) *StringSliceCmd
func (c *Ring) ZRangeByLex(key string, opt ZRangeBy) *StringSliceCmd
func (c *Ring) ZRangeByScore(key string, opt ZRangeBy) *StringSliceCmd
func (c *Ring) ZRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd
func (c *Ring) ZRangeWithScores(key string, start, stop int64) *ZSliceCmd
func (c *Ring) ZRank(key, member string) *IntCmd
func (c *Ring) ZRem(key string, members ...interface{}) *IntCmd
func (c *Ring) ZRemRangeByLex(key, min, max string) *IntCmd
func (c *Ring) ZRemRangeByRank(key string, start, stop int64) *IntCmd
func (c *Ring) ZRemRangeByScore(key, min, max string) *IntCmd
func (c *Ring) ZRevRange(key string, start, stop int64) *StringSliceCmd
func (c *Ring) ZRevRangeByLex(key string, opt ZRangeBy) *StringSliceCmd
func (c *Ring) ZRevRangeByScore(key string, opt ZRangeBy) *StringSliceCmd
func (c *Ring) ZRevRangeByScoreWithScores(key string, opt ZRangeBy) *ZSliceCmd
func (c *Ring) ZRevRangeWithScores(key string, start, stop int64) *ZSliceCmd
func (c *Ring) ZRevRank(key, member string) *IntCmd
func (c *Ring) ZScan(key string, cursor uint64, match string, count int64) *ScanCmd
func (c *Ring) ZScore(key, member string) *FloatCmd
func (c *Ring) ZUnionStore(dest string, store ZStore, keys ...string) *IntCmd
RingOptions are used to configure a ring client and should be passed to NewRing.
type RingOptions struct { // Map of name => host:port addresses of ring shards. Addrs map[string]string // Frequency of PING commands sent to check shards availability. // Shard is considered down after 3 subsequent failed checks. HeartbeatFrequency time.Duration // Hash function used in consistent hash. // Default is crc32.ChecksumIEEE. Hash Hash // Number of replicas in consistent hash. // Default is 100 replicas. // // Higher number of replicas will provide less deviation, that is keys will be // distributed to nodes more evenly. // // Following is deviation for common nreplicas: // -------------------------------------------------------- // | nreplicas | standard error | 99% confidence interval | // | 10 | 0.3152 | (0.37, 1.98) | // | 100 | 0.0997 | (0.76, 1.28) | // | 1000 | 0.0316 | (0.92, 1.09) | // -------------------------------------------------------- // // See https://arxiv.org/abs/1406.2294 for reference HashReplicas int OnConnect func(*Conn) error DB int Password string 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 }
type ScanCmd struct {
// contains filtered or unexported fields
}
func NewScanCmd(process func(cmd Cmder) error, args ...interface{}) *ScanCmd
func NewScanCmdResult(keys []string, cursor uint64, err error) *ScanCmd
NewScanCmdResult returns a ScanCmd initialised with val and err for testing
func (cmd *ScanCmd) Args() []interface{}
func (cmd *ScanCmd) Err() error
func (cmd *ScanCmd) Iterator() *ScanIterator
Iterator creates a new ScanIterator.
▹ Example
func (cmd *ScanCmd) Name() string
func (cmd *ScanCmd) Result() (keys []string, cursor uint64, err error)
func (cmd *ScanCmd) String() string
func (cmd *ScanCmd) Val() (keys []string, cursor uint64)
ScanIterator is used to incrementally iterate over a collection of elements. It's safe for concurrent use by multiple goroutines.
type ScanIterator struct {
// contains filtered or unexported fields
}
▹ Example
func (it *ScanIterator) Err() error
Err returns the last iterator error, if any.
func (it *ScanIterator) Next() bool
Next advances the cursor and returns true if more values can be read.
func (it *ScanIterator) Val() string
Val returns the key/field at the current cursor position.
type Script struct {
// contains filtered or unexported fields
}
▹ Example
func NewScript(src string) *Script
func (s *Script) Eval(c scripter, keys []string, args ...interface{}) *Cmd
func (s *Script) EvalSha(c scripter, keys []string, args ...interface{}) *Cmd
func (s *Script) Exists(c scripter) *BoolSliceCmd
func (s *Script) Hash() string
func (s *Script) Load(c scripter) *StringCmd
func (s *Script) Run(c scripter, keys []string, args ...interface{}) *Cmd
Run optimistically uses EVALSHA to run the script. If script does not exist it is retried using EVAL.
type SentinelClient struct {
// contains filtered or unexported fields
}
func NewSentinelClient(opt *Options) *SentinelClient
func (c *SentinelClient) 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 (c *SentinelClient) Do(args ...interface{}) *Cmd
Do creates a Cmd from the args and processes the cmd.
func (c *SentinelClient) Failover(name string) *StatusCmd
Failover forces a failover as if the master was not reachable, and without asking for agreement to other Sentinels.
func (c *SentinelClient) FlushConfig() *StatusCmd
FlushConfig forces Sentinel to rewrite its configuration on disk, including the current Sentinel state.
func (c *SentinelClient) GetMasterAddrByName(name string) *StringSliceCmd
func (c *SentinelClient) Master(name string) *StringStringMapCmd
Master shows the state and info of the specified master.
func (c *SentinelClient) PSubscribe(channels ...string) *PubSub
PSubscribe subscribes the client to the given patterns. Patterns can be omitted to create empty subscription.
func (c *SentinelClient) Process(cmd Cmder) error
func (c *SentinelClient) Reset(pattern string) *IntCmd
Reset resets all the masters with matching name. The pattern argument is a glob-style pattern. The reset process clears any previous state in a master (including a failover in progress), and removes every slave and sentinel already discovered and associated with the master.
func (c *SentinelClient) Sentinels(name string) *SliceCmd
func (c *SentinelClient) String() string
func (c *SentinelClient) Subscribe(channels ...string) *PubSub
Subscribe subscribes the client to the specified channels. Channels can be omitted to create empty subscription.
func (c *SentinelClient) WrapProcess( fn func(oldProcess func(cmd Cmder) error) func(cmd Cmder) error, )
WrapProcess wraps function that processes Redis commands.
func (c *SentinelClient) WrapProcessPipeline( fn func(oldProcess func([]Cmder) error) func([]Cmder) error, )
type SliceCmd struct {
// contains filtered or unexported fields
}
func NewSliceCmd(args ...interface{}) *SliceCmd
func NewSliceResult(val []interface{}, err error) *SliceCmd
NewSliceResult returns a SliceCmd initialised with val and err for testing
func (cmd *SliceCmd) Args() []interface{}
func (cmd *SliceCmd) Err() error
func (cmd *SliceCmd) Name() string
func (cmd *SliceCmd) Result() ([]interface{}, error)
func (cmd *SliceCmd) String() string
func (cmd *SliceCmd) Val() []interface{}
type Sort struct { By string Offset, Count int64 Get []string Order string Alpha bool }
type StatefulCmdable interface { Cmdable Auth(password string) *StatusCmd Select(index int) *StatusCmd SwapDB(index1, index2 int) *StatusCmd ClientSetName(name string) *BoolCmd }
type StatusCmd struct {
// contains filtered or unexported fields
}
func NewStatusCmd(args ...interface{}) *StatusCmd
func NewStatusResult(val string, err error) *StatusCmd
NewStatusResult returns a StatusCmd initialised with val and err for testing
func (cmd *StatusCmd) Args() []interface{}
func (cmd *StatusCmd) Err() error
func (cmd *StatusCmd) Name() string
func (cmd *StatusCmd) Result() (string, error)
func (cmd *StatusCmd) String() string
func (cmd *StatusCmd) Val() string
type StringCmd struct {
// contains filtered or unexported fields
}
func NewStringCmd(args ...interface{}) *StringCmd
func NewStringResult(val string, err error) *StringCmd
NewStringResult returns a StringCmd initialised with val and err for testing
func (cmd *StringCmd) Args() []interface{}
func (cmd *StringCmd) Bytes() ([]byte, error)
func (cmd *StringCmd) Err() error
func (cmd *StringCmd) Float32() (float32, error)
func (cmd *StringCmd) Float64() (float64, error)
func (cmd *StringCmd) Int() (int, error)
func (cmd *StringCmd) Int64() (int64, error)
func (cmd *StringCmd) Name() string
func (cmd *StringCmd) Result() (string, error)
func (cmd *StringCmd) Scan(val interface{}) error
func (cmd *StringCmd) String() string
func (cmd *StringCmd) Uint64() (uint64, error)
func (cmd *StringCmd) Val() string
type StringIntMapCmd struct {
// contains filtered or unexported fields
}
func NewStringIntMapCmd(args ...interface{}) *StringIntMapCmd
func NewStringIntMapCmdResult(val map[string]int64, err error) *StringIntMapCmd
NewStringIntMapCmdResult returns a StringIntMapCmd initialised with val and err for testing
func (cmd *StringIntMapCmd) Args() []interface{}
func (cmd *StringIntMapCmd) Err() error
func (cmd *StringIntMapCmd) Name() string
func (cmd *StringIntMapCmd) Result() (map[string]int64, error)
func (cmd *StringIntMapCmd) String() string
func (cmd *StringIntMapCmd) Val() map[string]int64
type StringSliceCmd struct {
// contains filtered or unexported fields
}
func NewStringSliceCmd(args ...interface{}) *StringSliceCmd
func NewStringSliceResult(val []string, err error) *StringSliceCmd
NewStringSliceResult returns a StringSliceCmd initialised with val and err for testing
func (cmd *StringSliceCmd) Args() []interface{}
func (cmd *StringSliceCmd) Err() error
func (cmd *StringSliceCmd) Name() string
func (cmd *StringSliceCmd) Result() ([]string, error)
func (cmd *StringSliceCmd) ScanSlice(container interface{}) error
func (cmd *StringSliceCmd) String() string
func (cmd *StringSliceCmd) Val() []string
type StringStringMapCmd struct {
// contains filtered or unexported fields
}
func NewStringStringMapCmd(args ...interface{}) *StringStringMapCmd
func NewStringStringMapResult(val map[string]string, err error) *StringStringMapCmd
NewStringStringMapResult returns a StringStringMapCmd initialised with val and err for testing
func (cmd *StringStringMapCmd) Args() []interface{}
func (cmd *StringStringMapCmd) Err() error
func (cmd *StringStringMapCmd) Name() string
func (cmd *StringStringMapCmd) Result() (map[string]string, error)
func (cmd *StringStringMapCmd) String() string
func (cmd *StringStringMapCmd) Val() map[string]string
type StringStructMapCmd struct {
// contains filtered or unexported fields
}
func NewStringStructMapCmd(args ...interface{}) *StringStructMapCmd
func (cmd *StringStructMapCmd) Args() []interface{}
func (cmd *StringStructMapCmd) Err() error
func (cmd *StringStructMapCmd) Name() string
func (cmd *StringStructMapCmd) Result() (map[string]struct{}, error)
func (cmd *StringStructMapCmd) String() string
func (cmd *StringStructMapCmd) Val() map[string]struct{}
Subscription received after a successful subscription to channel.
type Subscription struct { // Can be "subscribe", "unsubscribe", "psubscribe" or "punsubscribe". Kind string // Channel name we have subscribed to. Channel string // Number of channels we are currently subscribed to. Count int }
func (m *Subscription) String() string
type TimeCmd struct {
// contains filtered or unexported fields
}
func NewTimeCmd(args ...interface{}) *TimeCmd
func (cmd *TimeCmd) Args() []interface{}
func (cmd *TimeCmd) Err() error
func (cmd *TimeCmd) Name() string
func (cmd *TimeCmd) Result() (time.Time, error)
func (cmd *TimeCmd) String() string
func (cmd *TimeCmd) Val() time.Time
Tx implements Redis transactions as described in http://redis.io/topics/transactions. It's NOT safe for concurrent use by multiple goroutines, because Exec resets list of watched keys. If you don't need WATCH it is better to use Pipeline.
type Tx struct {
// contains filtered or unexported fields
}
func (c *Tx) Auth(password string) *StatusCmd
func (c *Tx) ClientSetName(name string) *BoolCmd
ClientSetName assigns a name to the connection.
func (c *Tx) Close() error
Close closes the transaction, releasing any open resources.
func (c *Tx) Do(args ...interface{}) *Cmd
Do creates a Cmd from the args and processes the cmd.
func (c *Tx) Pipeline() Pipeliner
Pipeline creates a new pipeline. It is more convenient to use Pipelined.
func (c *Tx) Pipelined(fn func(Pipeliner) error) ([]Cmder, error)
Pipelined executes commands queued in the fn in a transaction.
When using WATCH, EXEC will execute commands only if the watched keys were not modified, allowing for a check-and-set mechanism.
Exec always returns list of commands. If transaction fails TxFailedErr is returned. Otherwise Exec returns an error of the first failed command or nil.
func (c *Tx) Process(cmd Cmder) error
func (c *Tx) Select(index int) *StatusCmd
func (c *Tx) String() string
func (c *Tx) SwapDB(index1, index2 int) *StatusCmd
func (c *Tx) TxPipeline() Pipeliner
TxPipeline is an alias for Pipeline.
func (c *Tx) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error)
TxPipelined is an alias for Pipelined.
func (c *Tx) Unwatch(keys ...string) *StatusCmd
Unwatch flushes all the previously watched keys for a transaction.
func (c *Tx) Watch(keys ...string) *StatusCmd
Watch marks the keys to be watched for conditional execution of a transaction.
func (c *Tx) WrapProcess( fn func(oldProcess func(cmd Cmder) error) func(cmd Cmder) error, )
WrapProcess wraps function that processes Redis commands.
func (c *Tx) WrapProcessPipeline( fn func(oldProcess func([]Cmder) error) func([]Cmder) error, )
UniversalClient is an abstract client which - based on the provided options - can connect to either clusters, or sentinel-backed failover instances or simple single-instance servers. This can be useful for testing cluster-specific applications locally.
type UniversalClient interface { Cmdable Watch(fn func(*Tx) error, keys ...string) error Process(cmd Cmder) error WrapProcess(fn func(oldProcess func(cmd Cmder) error) func(cmd Cmder) error) WrapProcessPipeline(fn func(oldProcess func([]Cmder) error) func([]Cmder) error) Subscribe(channels ...string) *PubSub PSubscribe(channels ...string) *PubSub Close() error }
func NewUniversalClient(opts *UniversalOptions) UniversalClient
NewUniversalClient returns a new multi client. The type of client returned depends on the following three conditions:
1. if a MasterName is passed a sentinel-backed FailoverClient will be returned 2. if the number of Addrs is two or more, a ClusterClient will be returned 3. otherwise, a single-node redis Client will be returned.
▹ Example (Cluster)
▹ Example (Failover)
▹ Example (Simple)
UniversalOptions information is required by UniversalClient to establish connections.
type UniversalOptions struct { // Either a single address or a seed list of host:port addresses // of cluster/sentinel nodes. Addrs []string // Database to be selected after connecting to the server. // Only single-node and failover clients. DB int OnConnect func(*Conn) error Password string 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 MaxRedirects int ReadOnly bool RouteByLatency bool RouteRandomly bool // The sentinel master name. // Only failover clients. MasterName string }
type XAddArgs struct { Stream string MaxLen int64 // MAXLEN N MaxLenApprox int64 // MAXLEN ~ N ID string Values map[string]interface{} }
type XClaimArgs struct { Stream string Group string Consumer string MinIdle time.Duration Messages []string }
type XMessage struct { ID string Values map[string]interface{} }
type XMessageSliceCmd struct {
// contains filtered or unexported fields
}
func NewXMessageSliceCmd(args ...interface{}) *XMessageSliceCmd
func (cmd *XMessageSliceCmd) Args() []interface{}
func (cmd *XMessageSliceCmd) Err() error
func (cmd *XMessageSliceCmd) Name() string
func (cmd *XMessageSliceCmd) Result() ([]XMessage, error)
func (cmd *XMessageSliceCmd) String() string
func (cmd *XMessageSliceCmd) Val() []XMessage
type XPending struct { Count int64 Lower string Higher string Consumers map[string]int64 }
type XPendingCmd struct {
// contains filtered or unexported fields
}
func NewXPendingCmd(args ...interface{}) *XPendingCmd
func (cmd *XPendingCmd) Args() []interface{}
func (cmd *XPendingCmd) Err() error
func (cmd *XPendingCmd) Name() string
func (cmd *XPendingCmd) Result() (*XPending, error)
func (cmd *XPendingCmd) String() string
func (cmd *XPendingCmd) Val() *XPending
type XPendingExt struct { Id string Consumer string Idle time.Duration RetryCount int64 }
type XPendingExtArgs struct { Stream string Group string Start string End string Count int64 Consumer string }
type XPendingExtCmd struct {
// contains filtered or unexported fields
}
func NewXPendingExtCmd(args ...interface{}) *XPendingExtCmd
func (cmd *XPendingExtCmd) Args() []interface{}
func (cmd *XPendingExtCmd) Err() error
func (cmd *XPendingExtCmd) Name() string
func (cmd *XPendingExtCmd) Result() ([]XPendingExt, error)
func (cmd *XPendingExtCmd) String() string
func (cmd *XPendingExtCmd) Val() []XPendingExt
type XReadArgs struct { Streams []string Count int64 Block time.Duration }
type XReadGroupArgs struct { Group string Consumer string // List of streams and ids. Streams []string Count int64 Block time.Duration NoAck bool }
type XStream struct { Stream string Messages []XMessage }
type XStreamSliceCmd struct {
// contains filtered or unexported fields
}
func NewXStreamSliceCmd(args ...interface{}) *XStreamSliceCmd
func (cmd *XStreamSliceCmd) Args() []interface{}
func (cmd *XStreamSliceCmd) Err() error
func (cmd *XStreamSliceCmd) Name() string
func (cmd *XStreamSliceCmd) Result() ([]XStream, error)
func (cmd *XStreamSliceCmd) String() string
func (cmd *XStreamSliceCmd) Val() []XStream
Z represents sorted set member.
type Z struct { Score float64 Member interface{} }
type ZRangeBy struct { Min, Max string Offset, Count int64 }
type ZSliceCmd struct {
// contains filtered or unexported fields
}
func NewZSliceCmd(args ...interface{}) *ZSliceCmd
func NewZSliceCmdResult(val []Z, err error) *ZSliceCmd
NewZSliceCmdResult returns a ZSliceCmd initialised with val and err for testing
func (cmd *ZSliceCmd) Args() []interface{}
func (cmd *ZSliceCmd) Err() error
func (cmd *ZSliceCmd) Name() string
func (cmd *ZSliceCmd) Result() ([]Z, error)
func (cmd *ZSliceCmd) String() string
func (cmd *ZSliceCmd) Val() []Z
ZStore is used as an arg to ZInterStore and ZUnionStore.
type ZStore struct { Weights []float64 // Can be SUM, MIN or MAX. Aggregate string }
ZWithKey represents sorted set member including the name of the key where it was popped.
type ZWithKey struct { Z Key string }
type ZWithKeyCmd struct {
// contains filtered or unexported fields
}
func NewZWithKeyCmd(args ...interface{}) *ZWithKeyCmd
func (cmd *ZWithKeyCmd) Args() []interface{}
func (cmd *ZWithKeyCmd) Err() error
func (cmd *ZWithKeyCmd) Name() string
func (cmd *ZWithKeyCmd) Result() (ZWithKey, error)
func (cmd *ZWithKeyCmd) String() string
func (cmd *ZWithKeyCmd) Val() ZWithKey
Name | Synopsis |
---|---|
.. |