aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorBogdan Gusiev <agresso@gmail.com>2018-03-31 18:29:08 +0300
committerBogdan Gusiev <agresso@gmail.com>2018-04-04 17:49:06 +0300
commitfb75c891ac7fe7331a9a967a96c674ed35eabdcf (patch)
tree5683c189e08dedcf938c9b808593a26e30d23835 /activerecord/lib
parentf339b098b20c7f6675d375cfa29828a911fe1b53 (diff)
downloadrails-fb75c891ac7fe7331a9a967a96c674ed35eabdcf.tar.gz
rails-fb75c891ac7fe7331a9a967a96c674ed35eabdcf.tar.bz2
rails-fb75c891ac7fe7331a9a967a96c674ed35eabdcf.zip
Optimize the code inside AR::QueryCache middleware
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/query_cache.rb15
1 files changed, 4 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/query_cache.rb b/activerecord/lib/active_record/query_cache.rb
index c8e340712d..28194c7c46 100644
--- a/activerecord/lib/active_record/query_cache.rb
+++ b/activerecord/lib/active_record/query_cache.rb
@@ -26,19 +26,12 @@ module ActiveRecord
end
def self.run
- ActiveRecord::Base.connection_handler.connection_pool_list.map do |pool|
- caching_was_enabled = pool.query_cache_enabled
-
- pool.enable_query_cache!
-
- [pool, caching_was_enabled]
- end
+ ActiveRecord::Base.connection_handler.connection_pool_list.
+ reject { |p| p.query_cache_enabled }.each { |p| p.enable_query_cache! }
end
- def self.complete(caching_pools)
- caching_pools.each do |pool, caching_was_enabled|
- pool.disable_query_cache! unless caching_was_enabled
- end
+ def self.complete(pools)
+ pools.each { |pool| pool.disable_query_cache! }
ActiveRecord::Base.connection_handler.connection_pool_list.each do |pool|
pool.release_connection if pool.active_connection? && !pool.connection.transaction_open?