Skip to content

Commit 4076e77

Browse files
author
Sylvester Chin
committed
perf: spread initialisation load across cluster
1 parent c22ca36 commit 4076e77

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/redis_client/cluster/command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class << self
2424
def load(nodes)
2525
cmd = errors = nil
2626

27-
nodes&.each do |node|
27+
nodes&.shuffle_each do |node|
2828
reply = node.call('COMMAND')
2929
commands = parse_command_reply(reply)
3030
cmd = ::RedisClient::Cluster::Command.new(commands)

lib/redis_client/cluster/node.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ def each(&block)
201201
@topology.clients.each_value(&block)
202202
end
203203

204+
def shuffle_each(&block)
205+
@topology.clients.values.shuffle!.each(&block)
206+
end
207+
204208
def sample
205209
@topology.clients.values.sample
206210
end

0 commit comments

Comments
 (0)