Permalink
Browse files

Avoid extra call to Cache#read in case of a fragment cache hit

  • Loading branch information...
1 parent 0ed8dea commit e54d9c1eb758d7f6f13f699e097c9f07a54d4970 @guilleiguaran guilleiguaran committed Jun 29, 2011
@@ -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 e54d9c1

Please sign in to comment.