Permalink
Browse files

Merge pull request #1896 from guilleiguaran/issue-1893

Avoid extra call to Cache#read in case of a fragment cache hit (3-0-stable)
  • Loading branch information...
tenderlove committed Jun 29, 2011
2 parents 0ed8dea + e54d9c1 commit a657a4b21c800e155e84b3b5d6a18ff0716c4da5
@@ -46,8 +46,8 @@ def cache(name = {}, options = nil, &block)
private
# TODO: Create an object that has caching read/write on it
def fragment_for(name = {}, options = nil, &block) #:nodoc:
- if controller.fragment_exist?(name, options)
- controller.read_fragment(name, options)
+ if fragment = controller.read_fragment(name, options)
+ fragment
else
# VIEW TODO: Make #capture usable outside of ERB
# This dance is needed because Builder can't use capture
@@ -153,7 +153,7 @@ def test_with_fragment_cache
wait
assert_equal 4, logs.size
- assert_match /Exist fragment\? views\/foo/, logs[1]
+ assert_match /Read fragment views\/foo/, logs[1]
assert_match /Write fragment views\/foo/, logs[2]
ensure
@controller.config.perform_caching = true

0 comments on commit a657a4b

Please sign in to comment.