1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Use the query cache iff Active Record is configured.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6202 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper 2007-02-22 08:14:47 +00:00
parent c8f7860d50
commit f425bba9cf

View file

@ -88,12 +88,20 @@ module ActiveRecord
query_caches[self] = cache
end
# Use a query cache within the given block.
def cache
# Don't cache if Active Record is not configured.
if ActiveRecord::Base.configurations.blank?
yield
else
begin
self.query_cache = QueryCache.new(connection_without_query_cache)
yield
ensure
self.query_cache = nil
end
end
end
def connection
query_cache || connection_without_query_cache