Skip to content

Commit d9fe424

Browse files
authored
perf: spread initialisation load across cluster (#239)
2 parents c22ca36 + 5e3d396 commit d9fe424

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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 shuffled_nodes
205+
@topology.clients.values.shuffle
206+
end
207+
204208
def sample
205209
@topology.clients.values.sample
206210
end

lib/redis_client/cluster/router.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def initialize(config, pool: nil, **kwargs)
2323
@pool = pool
2424
@client_kwargs = kwargs
2525
@node = fetch_cluster_info(@config, pool: @pool, **@client_kwargs)
26-
@command = ::RedisClient::Cluster::Command.load(@node)
26+
@command = ::RedisClient::Cluster::Command.load(@node.shuffled_nodes)
2727
@mutex = Mutex.new
2828
@command_builder = @config.command_builder
2929
end

0 commit comments

Comments
 (0)