mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
speeding up query cache
This commit is contained in:
parent
7104122cc3
commit
9ce0211806
2 changed files with 4 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue