Created
June 20, 2019 22:00
-
-
Save BetterProgramming/ce8bef146a354e59df949aa6bd9c921d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
threads << Thread.new do ActiveRecord::Base.connection_pool.with_connection do | |
# needed because otherwise the connection pool can run | |
# out of connections | |
t = Thread.current | |
t[:variable_name] = Model.find_by(column: data) | |
end | |
end | |
joined_threads = threads.map &:join | |
# do something with the thread local variable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment