提交 f425bba9 编写于 作者: J Jeremy Kemper

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
上级 c8f7860d
......@@ -87,14 +87,22 @@ def query_cache
def query_cache=(cache)
query_caches[self] = cache
end
def cache
self.query_cache = QueryCache.new(connection_without_query_cache)
yield
ensure
self.query_cache = nil
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
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册