mirror of https://github.com/go-redis/redis.git
Add basic example how to use Redis Cluster. Unify comments.
This commit is contained in:
parent
1eb3e076ed
commit
f6ef0fd342
|
@ -26,8 +26,8 @@ type ClusterClient struct {
|
|||
reloading uint32
|
||||
}
|
||||
|
||||
// NewClusterClient initializes a new cluster-aware client using given options.
|
||||
// A list of seed addresses must be provided.
|
||||
// NewClusterClient returns a new Redis Cluster client as described in
|
||||
// http://redis.io/topics/cluster-spec.
|
||||
func NewClusterClient(opt *ClusterOptions) *ClusterClient {
|
||||
client := &ClusterClient{
|
||||
addrs: opt.Addrs,
|
||||
|
|
|
@ -31,10 +31,22 @@ func ExampleNewClient() {
|
|||
}
|
||||
|
||||
func ExampleNewFailoverClient() {
|
||||
redis.NewFailoverClient(&redis.FailoverOptions{
|
||||
// See http://redis.io/topics/sentinel for instructions how to
|
||||
// setup Redis Sentinel.
|
||||
client := redis.NewFailoverClient(&redis.FailoverOptions{
|
||||
MasterName: "master",
|
||||
SentinelAddrs: []string{":26379"},
|
||||
})
|
||||
client.Ping()
|
||||
}
|
||||
|
||||
func ExampleNewClusterClient() {
|
||||
// See http://redis.io/topics/cluster-tutorial for instructions
|
||||
// how to setup Redis Cluster.
|
||||
client := redis.NewClusterClient(&redis.ClusterOptions{
|
||||
Addrs: []string{":7000", ":7001", ":7002", ":7003", ":7004", ":7005"},
|
||||
})
|
||||
client.Ping()
|
||||
}
|
||||
|
||||
func ExampleClient() {
|
||||
|
|
|
@ -84,7 +84,7 @@ func (opt *FailoverOptions) options() *options {
|
|||
}
|
||||
}
|
||||
|
||||
// NewFailoverClient returns Redis client with automatic failover
|
||||
// NewFailoverClient returns a Redis client with automatic failover
|
||||
// capabilities using Redis Sentinel.
|
||||
func NewFailoverClient(failoverOpt *FailoverOptions) *Client {
|
||||
opt := failoverOpt.options()
|
||||
|
|
Loading…
Reference in New Issue