| 143 | } |
| 144 | |
| 145 | func (n *ClusterNode) GetClient() *redis.Client { |
| 146 | if client, ok := clients.Load(n.ID()); ok { |
| 147 | if rdsClient, ok := client.(*redis.Client); ok { |
| 148 | return rdsClient |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | client := redis.NewClient(&redis.Options{ |
| 153 | Addr: n.addr, |
| 154 | Password: n.password, |
| 155 | DialTimeout: dialTimeout, |
| 156 | ReadTimeout: readTimeout, |
| 157 | WriteTimeout: writeTimeout, |
| 158 | MaxRetries: -1, // don't retry inside the client |
| 159 | MinIdleConns: minIdleConns, |
| 160 | }) |
| 161 | clients.Store(n.ID(), client) |
| 162 | return client |
| 163 | } |
| 164 | |
| 165 | func (n *ClusterNode) CheckClusterMode(ctx context.Context) (int64, error) { |
| 166 | clusterInfo, err := n.GetClusterInfo(ctx) |