Dont expire or read fragments if caching is turned off

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1270 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 577a22c4
......@@ -276,6 +276,8 @@ def cache_erb_fragment(block, name = {}, options = {})
end
def write_fragment(name, content, options = {})
return unless perform_caching
key = fragment_cache_key(name)
fragment_cache_store.write(key, content, options)
logger.info "Cached fragment: #{key}" unless logger.nil?
......@@ -283,6 +285,8 @@ def write_fragment(name, content, options = {})
end
def read_fragment(name, options = {})
return unless perform_caching
key = fragment_cache_key(name)
if cache = fragment_cache_store.read(key, options)
logger.info "Fragment hit: #{key}" unless logger.nil?
......@@ -297,6 +301,8 @@ def read_fragment(name, options = {})
# * Hash: Is treated as an implicit call to url_for, like { :controller => "pages", :action => "notes", :id => 45 }
# * Regexp: Will destroy all the matched fragments, example: %r{pages/\d*/notes}
def expire_fragment(name, options = {})
return unless perform_caching
key = fragment_cache_key(name)
if key.is_a?(Regexp)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册