Skip to content

Commit 041b904

Browse files
songjizrosa
authored andcommitted
improve memory usage for releasable concurrency keys
1 parent fe57349 commit 041b904

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/models/solid_queue/blocked_execution.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ def release_one(concurrency_key)
3030

3131
private
3232
def releasable(concurrency_keys)
33-
semaphores = Semaphore.where(key: concurrency_keys).select(:key, :value).index_by(&:key)
33+
semaphores = Semaphore.where(key: concurrency_keys).pluck(:key, :value).to_h
3434

3535
# Concurrency keys without semaphore + concurrency keys with open semaphore
36-
(concurrency_keys - semaphores.keys) | semaphores.select { |key, semaphore| semaphore.value > 0 }.map(&:first)
36+
(concurrency_keys - semaphores.keys) | semaphores.select { |_key, value| value > 0 }.keys
3737
end
3838
end
3939

0 commit comments

Comments
 (0)