aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-11-17 23:32:57 +1030
committerGitHub <noreply@github.com>2017-11-17 23:32:57 +1030
commitcd3c0fa3d04b634e272b4f5b232fdd433b3238f4 (patch)
treeef897de8b6eba83b6564e0e561b7f8b6733a5f84 /activerecord/lib/active_record
parentc39ed435eb578c79867552c66da7eeb035fa58ad (diff)
parent11e32c1d841c08bd85842eb059fbf30536e804dc (diff)
downloadrails-cd3c0fa3d04b634e272b4f5b232fdd433b3238f4.tar.gz
rails-cd3c0fa3d04b634e272b4f5b232fdd433b3238f4.tar.bz2
rails-cd3c0fa3d04b634e272b4f5b232fdd433b3238f4.zip
Merge pull request #28869 from eugeneius/query_cache_all_pools
Enable query cache on all connection 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 3d5babb8b7..8e23128333 100644
--- a/activerecord/lib/active_record/query_cache.rb
+++ b/activerecord/lib/active_record/query_cache.rb
@@ -26,16 +26,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?