aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-10-27 14:23:01 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-10-27 14:23:01 -0700
commit9ce02118061fda778e592be83f7c4c3c7c75bfbf (patch)
tree5d390adc97d07802c2976c006a7f7ed21637051b /activerecord
parent7104122cc3fca4939d77a6780910cd98ff02fab0 (diff)
downloadrails-9ce02118061fda778e592be83f7c4c3c7c75bfbf.tar.gz
rails-9ce02118061fda778e592be83f7c4c3c7c75bfbf.tar.bz2
rails-9ce02118061fda778e592be83f7c4c3c7c75bfbf.zip
speeding up query cache
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb7
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_adapter.rb2
2 files changed, 4 insertions, 5 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 cbc09dfc3b..6ec023f0e5 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
@@ -59,14 +59,13 @@ module ActiveRecord
private
def cache_sql(sql, binds)
- key = [sql, binds]
result =
- if @query_cache.has_key?(key)
+ if @query_cache[sql].key?(binds)
ActiveSupport::Notifications.instrument("sql.active_record",
:sql => sql, :name => "CACHE", :connection_id => self.object_id)
- @query_cache[key]
+ @query_cache[sql][binds]
else
- @query_cache[key] = yield
+ @query_cache[sql][binds] = yield
end
if Array === result
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
index 42d6f2bb21..f3fba9a3a9 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -41,7 +41,7 @@ module ActiveRecord
@active = nil
@connection, @logger = connection, logger
@query_cache_enabled = false
- @query_cache = {}
+ @query_cache = Hash.new { |h,sql| h[sql] = {} }
@instrumenter = ActiveSupport::Notifications.instrumenter
end