Documentation ¶
Index ¶
- func GetSlot(arg interface{}) (uint16, error)
- type Batch
- type Cluster
- func (cluster *Cluster) ChooseNodeWithCmd(cmd string, args ...interface{}) (*redisNode, error)
- func (cluster *Cluster) Close()
- func (cluster *Cluster) Do(cmd string, args ...interface{}) (interface{}, error)
- func (cluster *Cluster) IterateNodes(result func(string, interface{}, error), cmd string, args ...interface{})
- func (cluster *Cluster) NewBatch() *Batch
- func (cluster *Cluster) NewBatcher() common.CmdBatcher
- func (cluster *Cluster) RunBatch(bat *Batch) ([]interface{}, error)
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch pack multiple commands, which should be supported by Do method.
func (*Batch) GetBatchSize ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster is a redis client that manage connections to redis nodes, cache and update cluster info, and execute all kinds of commands. Multiple goroutines may invoke methods on a cluster simutaneously.
func NewCluster ¶
NewCluster create a new redis cluster client with specified options.
func (*Cluster) ChooseNodeWithCmd ¶
func (*Cluster) Close ¶
func (cluster *Cluster) Close()
Close cluster connection, any subsequent method call will fail.
func (*Cluster) Do ¶
Do excute a redis command with random number arguments. First argument will be used as key to hash to a slot, so it only supports a subset of redis commands. / SUPPORTED: most commands of keys, strings, lists, sets, sorted sets, hashes. NOT SUPPORTED: scripts, transactions, clusters.
Particularly, MSET/MSETNX/MGET are supported using result aggregation. To MSET/MSETNX, there's no atomicity gurantee that given keys are set at once. It's possible that some keys are set, while others not.
See README.md for more details. See full redis command list: http://www.redis.io/commands
func (*Cluster) IterateNodes ¶
func (*Cluster) NewBatcher ¶
func (cluster *Cluster) NewBatcher() common.CmdBatcher
type Options ¶
type Options struct { StartNodes []string // Startup nodes ConnTimeout time.Duration // Connection timeout ReadTimeout time.Duration // Read timeout WriteTimeout time.Duration // Write timeout KeepAlive int // Maximum keep alive connecion in each node AliveTime time.Duration // Keep alive timeout Password string HandleMoveError bool HandleAskError bool // contains filtered or unexported fields }
Options is used to initialize a new redis cluster.