redis-cluster-client 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redis_client/cluster/node.rb +5 -8
- data/lib/redis_client/cluster.rb +2 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fce5f4a15cfcab3d7cca37052e9f85ad45abcee8f4de9e458fc560a01382842
|
4
|
+
data.tar.gz: 2da9fb7a3ae8836dd7606fbfd05e33f423529716493d3bb8fccd6d01bae10bc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd4b929261fe0a50f4b13fe4963550e7b8c1197ee4f813a464b309140b29d7cc75a95259f100481d2f7e5a958a98608aca980e8308dca125200c1acb4e506e06
|
7
|
+
data.tar.gz: b41237f574ca12b3826e8d869f3ea3251a0acb41961fb009efe7bb5d2f07517b17cae80c5161da91603b4586a63beef11ba618b6386cfd684012cc7fa09752d1
|
@@ -129,19 +129,17 @@ class RedisClient
|
|
129
129
|
def call_replica(method, *command, **kwargs, &block)
|
130
130
|
return call_primary(method, *command, **kwargs, &block) if replica_disabled?
|
131
131
|
|
132
|
+
replica_node_keys = @replications.values.map(&:sample)
|
132
133
|
try_map do |node_key, client|
|
133
|
-
next if primary?(node_key)
|
134
|
+
next if primary?(node_key) || !replica_node_keys.include?(node_key)
|
134
135
|
|
135
136
|
client.send(method, *command, **kwargs, &block)
|
136
137
|
end.values
|
137
138
|
end
|
138
139
|
|
139
140
|
def scale_reading_clients
|
140
|
-
|
141
|
-
|
142
|
-
end
|
143
|
-
|
144
|
-
clients.values.sort_by do |client|
|
141
|
+
keys = replica_disabled? ? @replications.keys : @replications.values.map(&:first)
|
142
|
+
@clients.select { |k, _| keys.include?(k) }.values.sort_by do |client|
|
145
143
|
::RedisClient::Cluster::NodeKey.build_from_host_port(client.config.host, client.config.port)
|
146
144
|
end
|
147
145
|
end
|
@@ -184,7 +182,7 @@ class RedisClient
|
|
184
182
|
end
|
185
183
|
|
186
184
|
def replica?(node_key)
|
187
|
-
!(@replications.nil? || @replications.size.zero?) &&
|
185
|
+
!(@replications.nil? || @replications.size.zero?) && !@replications.key?(node_key)
|
188
186
|
end
|
189
187
|
|
190
188
|
def build_slot_node_mappings(node_info)
|
@@ -203,7 +201,6 @@ class RedisClient
|
|
203
201
|
node_info.each_with_object(Hash.new { |h, k| h[k] = [] }) do |info, acc|
|
204
202
|
primary_info = dict[info[:primary_id]]
|
205
203
|
acc[primary_info[:node_key]] << info[:node_key] unless primary_info.nil?
|
206
|
-
acc[info[:node_key]]
|
207
204
|
end
|
208
205
|
end
|
209
206
|
|
data/lib/redis_client/cluster.rb
CHANGED
@@ -40,13 +40,11 @@ class RedisClient
|
|
40
40
|
@size.zero?
|
41
41
|
end
|
42
42
|
|
43
|
-
def execute # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
44
|
-
all_replies =
|
43
|
+
def execute # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
44
|
+
all_replies = Array.new(@size)
|
45
45
|
threads = @grouped.map do |k, v|
|
46
46
|
Thread.new(@client, k, v) do |client, node_key, rows|
|
47
47
|
Thread.pass
|
48
|
-
|
49
|
-
node_key = node_key.nil? ? client.instance_variable_get(:@node).primary_node_keys.sample : node_key
|
50
48
|
replies = client.send(:find_node, node_key).pipelined do |pipeline|
|
51
49
|
rows.each do |row|
|
52
50
|
case row[1]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-cluster-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taishi Kasuga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis-client
|