Skip to content

Commit 413a70a

Browse files
authored
perf: lessen wasting memory allocation for Pub/Sub (#232)
1 parent 3600925 commit 413a70a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/redis_client/cluster/pub_sub.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ def next_event(timeout = nil)
6464

6565
max_duration = calc_max_duration(timeout)
6666
starting = obtain_current_time
67+
clients = @states.values
6768
loop do
6869
break if max_duration > 0 && obtain_current_time - starting > max_duration
6970

70-
@states.values.shuffle.each do |pubsub|
71+
clients.shuffle!
72+
clients.each do |pubsub|
7173
message = pubsub.take_message(timeout)
7274
return message if message
7375
end

0 commit comments

Comments
 (0)