3
3
4
4
Redis Cluster Client
5
5
===============================================================================
6
- This library is a client for Redis cluster.
6
+ This library is a client for [ Redis cluster] ( https://redis.io/docs/reference/cluster-spec/ ) .
7
7
It depends on [ redis-client] ( https://github.com/redis-rb/redis-client ) .
8
8
So it would be better to read ` redis-client ` documents first.
9
9
@@ -14,10 +14,10 @@ gem 'redis-cluster-client'
14
14
15
15
## Initialization
16
16
| key | type | default | description |
17
- | --- | --- |
18
- | ` nodes ` | ` String ` or ` Array<String, Hash> ` | ` ['redis://127.0.0.1:6379] ` | node addresses for startup connection |
19
- | ` replica ` | Boolean | ` false ` | ` true ` if client use scale read feature |
20
- | ` fixed_hostname ` | ` String ` | ` nil ` | specify if client connects to cluster with SSL and single endpoint |
17
+ | --- | --- | --- | --- |
18
+ | ` : nodes` | String or Array<String, Hash> | ` ['redis://127.0.0.1:6379' ] ` | node addresses for startup connection |
19
+ | ` : replica` | Boolean | ` false ` | ` true ` if client should use scale read feature |
20
+ | ` : fixed_hostname` | String | ` nil ` | required if client should connect to single endpoint with SSL |
21
21
22
22
Also, [ the other generic options] ( https://github.com/redis-rb/redis-client#configuration ) can be passed.
23
23
@@ -29,7 +29,7 @@ Also, [the other generic options](https://github.com/redis-rb/redis-client#confi
29
29
RedisClient .cluster.new_client
30
30
# => #<RedisClient::Cluster 172.20.0.2:6379, 172.20.0.6:6379, 172.20.0.7:6379>
31
31
32
- # To connect to all nodes and to use scale reading feature
32
+ # To connect to all nodes to use scale reading feature
33
33
RedisClient .cluster(replica: true ).new_client
34
34
# => #<RedisClient::Cluster 172.20.0.2:6379, 172.20.0.3:6379, 172.20.0.4:6379, 172.20.0.5:6379, 172.20.0.6:6379, 172.20.0.7:6379>
35
35
@@ -73,8 +73,19 @@ A part of commands can be passed multiple keys. But it has a constraint the keys
73
73
The following error occurs because keys must be in the same hash slot and not just the same node.
74
74
75
75
``` ruby
76
- RedisClient .cluster.new_client.call(' MGET' , ' key1' , ' key2' , ' key3' )
76
+ cli = RedisClient .cluster.new_client
77
+
78
+ cli.call(' MGET' , ' key1' , ' key2' , ' key3' )
77
79
# => CROSSSLOT Keys in request don't hash to the same slot (RedisClient::CommandError)
80
+
81
+ cli.call(' CLUSTER' , ' KEYSLOT' , ' key1' )
82
+ # => 9189
83
+
84
+ cli.call(' CLUSTER' , ' KEYSLOT' , ' key2' )
85
+ # => 4998
86
+
87
+ cli.call(' CLUSTER' , ' KEYSLOT' , ' key3' )
88
+ # => 935
78
89
```
79
90
80
91
## Connection pooling
0 commit comments