有这样一段 view 代码:
<% cache ['timelines', 'show', 'timeline-info', @timeline] do %>
<div class="span4 timeline-info">
<ul class="delimited">
<li>
<span class="menu-category">分类</span>
<% @timeline.catalogs.each do |catalog| %>
<%= link_to catalog.name, catalog_path(catalog) %>
<% end %>
</li>
</ul>
</div>
<% end %>
将其中的“分类”2 字修改、保存、刷新页面,发现 cache 没刷新
对比日志,可以看到 cache key 确实做了签名,但签名没有变化,why?
修改前:
Event Load (0.1ms) SELECT `events`.* FROM `events` WHERE `events`.`timeline_id` IN (3)
Cache read: views/timelines/show/timeline-info/timelines/3-20121112053010/e6bfaea5957ab05d7fd41135f2cd4713
Read fragment views/timelines/show/timeline-info/timelines/3-20121112053010/e6bfaea5957ab05d7fd41135f2cd4713 (0.3ms)
Rendered timelines/show/_timeline_info.html.erb (0.8ms)
修改后:
Timeline Load (0.1ms) SELECT `timelines`.* FROM `timelines` WHERE `timelines`.`published` = 1 AND `timelines`.`id` = 3 LIMIT 1
Event Load (0.1ms) SELECT `events`.* FROM `events` WHERE `events`.`timeline_id` IN (3)
Cache read: views/timelines/show/timeline-info/timelines/3-20121112053010/e6bfaea5957ab05d7fd41135f2cd4713
Read fragment views/timelines/show/timeline-info/timelines/3-20121112053010/e6bfaea5957ab05d7fd41135f2cd4713 (0.4ms)
Rendered timelines/show/_timeline_info.html.erb (0.9ms)
development.rb
config.action_controller.perform_caching = true
config.cache_store = :dalli_store
gem 'dalli'
gem 'cache_digests'