lib/interlock/action_view.rb in interlock-1.3 vs lib/interlock/action_view.rb in interlock-1.4
- old
+ new
@@ -28,11 +28,11 @@
== View caching without action caching
It's fine to use a <tt>view_cache</tt> block without a <tt>behavior_cache</tt> block. For example, to mimic regular fragment cache behavior, but take advantage of memcached's <tt>:ttl</tt> support, call:
- <% view_cache :ignore => :all, :tag => 'sidebar', :ttl => 5.minutes %>
+ <% view_cache :ignore => :all, :tag => 'sidebar', :ttl => 5.minutes do %>
<% end %>
== Dependencies, scoping, and other options
See ActionController::Base for explanations of the rest of the options. The <tt>view_cache</tt> and <tt>behavior_cache</tt> APIs are identical except for setting the <tt>:ttl</tt>, which can only be done in the view, and the default dependency, which is only set by <tt>behavior_cache</tt>.
@@ -42,23 +42,20 @@
# conventional_class = begin; controller.controller_name.classify.constantize; rescue NameError; end
options, dependencies = Interlock.extract_options_and_dependencies(args, nil)
key = controller.caching_key(options.value_for_indifferent_key(:ignore), options.value_for_indifferent_key(:tag))
- if options[:perform] == false
+ if options[:perform] == false || Interlock.config[:disabled]
# Interlock.say key, "is not cached"
block.call
else
Interlock.register_dependencies(dependencies, key)
# Interlock.say key, "is rendering"
@cached_content_for, previous_cached_content_for = {}, @cached_content_for
- @controller.cache_erb_fragment(
- block,
- key,
- :ttl => (options.value_for_indifferent_key(:ttl) or Interlock.config[:ttl])
- )
+
+ cache key, :ttl => (options.value_for_indifferent_key(:ttl) or Interlock.config[:ttl]), &block
# This is tricky. If we were already caching content_fors in a parent block, we need to
# append the content_fors set in the inner block to those already set in the outer block.
if previous_cached_content_for
@cached_content_for.each do |key, value|