Skip to content

Commit

Permalink
perf: spread initialisation load across cluster (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
supercaracal authored Aug 14, 2023
2 parents c22ca36 + 5e3d396 commit d9fe424
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/redis_client/cluster/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ def each(&block)
@topology.clients.each_value(&block)
end

def shuffled_nodes
@topology.clients.values.shuffle
end

def sample
@topology.clients.values.sample
end
Expand Down
2 changes: 1 addition & 1 deletion lib/redis_client/cluster/router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def initialize(config, pool: nil, **kwargs)
@pool = pool
@client_kwargs = kwargs
@node = fetch_cluster_info(@config, pool: @pool, **@client_kwargs)
@command = ::RedisClient::Cluster::Command.load(@node)
@command = ::RedisClient::Cluster::Command.load(@node.shuffled_nodes)
@mutex = Mutex.new
@command_builder = @config.command_builder
end
Expand Down

0 comments on commit d9fe424

Please sign in to comment.