aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-10-24 13:53:00 -0500
committerMatthew Draper <matthew@trebex.net>2016-10-27 00:48:35 -0500
commit09b6cc28bf2bd7c37289d5e9a3e04a04a1ec0db3 (patch)
tree118ba38efb0625d756a3e6f1f3ed0ba9434f9435 /activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
parentfa7efca553e325b2aabb087a4eddf4560c356094 (diff)
downloadrails-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/connection_adapters/abstract/query_cache.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb b/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
index 2f8a89e88e..3eac1b66ae 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
@@ -4,6 +4,7 @@ module ActiveRecord
class << self
def included(base) #:nodoc:
dirties_query_cache base, :insert, :update, :delete, :rollback_to_savepoint, :rollback_db_transaction
+ base.set_callback :checkin, :after, :disable_query_cache!
end
def dirties_query_cache(base, *method_names)
@@ -41,6 +42,7 @@ module ActiveRecord
def disable_query_cache!
@query_cache_enabled = false
+ clear_query_cache
end
# Disable the query cache within the block.