diff options
author | Matthew Draper <matthew@trebex.net> | 2016-10-24 13:53:00 -0500 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2016-10-27 00:48:35 -0500 |
commit | 09b6cc28bf2bd7c37289d5e9a3e04a04a1ec0db3 (patch) | |
tree | 118ba38efb0625d756a3e6f1f3ed0ba9434f9435 /activerecord/lib/active_record/query_cache.rb | |
parent | fa7efca553e325b2aabb087a4eddf4560c356094 (diff) | |
download | rails-09b6cc28bf2bd7c37289d5e9a3e04a04a1ec0db3.tar.gz rails-09b6cc28bf2bd7c37289d5e9a3e04a04a1ec0db3.tar.bz2 rails-09b6cc28bf2bd7c37289d5e9a3e04a04a1ec0db3.zip |
Clear query cache during checkin, instead of an execution callback
It doesn't make sense for the query cache to persist while a connection
moves through the pool and is assigned to a new thread.
[Samuel Cochran & Matthew Draper]
Diffstat (limited to 'activerecord/lib/active_record/query_cache.rb')
-rw-r--r-- | activerecord/lib/active_record/query_cache.rb | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/query_cache.rb b/activerecord/lib/active_record/query_cache.rb index c42c22ab09..23dae825c2 100644 --- a/activerecord/lib/active_record/query_cache.rb +++ b/activerecord/lib/active_record/query_cache.rb @@ -24,17 +24,10 @@ module ActiveRecord end def self.run - connection = ActiveRecord::Base.connection - enabled = connection.query_cache_enabled - connection.enable_query_cache! - - [connection, enabled] + ActiveRecord::Base.connection.enable_query_cache! end - def self.complete((connection, enabled)) - connection.clear_query_cache - connection.disable_query_cache! unless enabled - + def self.complete(_) unless ActiveRecord::Base.connected? && ActiveRecord::Base.connection.transaction_open? ActiveRecord::Base.clear_active_connections! end |