aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorEugene Kenny <elkenny@gmail.com>2017-04-24 23:26:13 +0100
committerEugene Kenny <elkenny@gmail.com>2017-04-24 23:26:13 +0100
commit11e32c1d841c08bd85842eb059fbf30536e804dc (patch)
treee683ed2f1901d11747f60e3dd6673342a16dd964 /activerecord/lib/active_record
parent0dd40fe72cfcf53b475a4084d61e9e931417c29e (diff)
downloadrails-11e32c1d841c08bd85842eb059fbf30536e804dc.tar.gz
rails-11e32c1d841c08bd85842eb059fbf30536e804dc.tar.bz2
rails-11e32c1d841c08bd85842eb059fbf30536e804dc.zip
Enable query cache on all connection pools
Since the query cache no longer eagerly checks out a connection, we can enable it on all connection pools at the start of every request, and it will only take effect for requests that actually use those pools.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/query_cache.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/query_cache.rb b/activerecord/lib/active_record/query_cache.rb
index ec246e97bc..92dd52b068 100644
--- a/activerecord/lib/active_record/query_cache.rb
+++ b/activerecord/lib/active_record/query_cache.rb
@@ -24,16 +24,19 @@ module ActiveRecord
end
def self.run
- caching_pool = ActiveRecord::Base.connection_pool
- caching_was_enabled = caching_pool.query_cache_enabled
+ ActiveRecord::Base.connection_handler.connection_pool_list.map do |pool|
+ caching_was_enabled = pool.query_cache_enabled
- caching_pool.enable_query_cache!
+ pool.enable_query_cache!
- [caching_pool, caching_was_enabled]
+ [pool, caching_was_enabled]
+ end
end
- def self.complete((caching_pool, caching_was_enabled))
- caching_pool.disable_query_cache! unless caching_was_enabled
+ def self.complete(caching_pools)
+ caching_pools.each do |pool, caching_was_enabled|
+ pool.disable_query_cache! unless caching_was_enabled
+ end
ActiveRecord::Base.connection_handler.connection_pool_list.each do |pool|
pool.release_connection if pool.active_connection? && !pool.connection.transaction_open?