1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

[ci skip] Document collection caching better.

Why are we here? Where did we come from? Where are we going... in 5 minutes?

These questions are not answered in this documentation. Instead collection
caching is better clarified. How it works, how it can share caches with
individual templates.
This commit is contained in:
Kasper Timm Hansen 2016-02-21 16:38:50 +01:00
parent e93f0f0f13
commit 4dbb7f0758

View file

@ -134,8 +134,21 @@ module ActionView
#
# <%= render partial: 'notifications/notification', collection: @notifications, cached: true %>
#
# The `cached: true` will make Action Views rendering issue a `read_multi` to
# the cache store instead of reading from it for every partial.
# The `cached: true` will make Action View's rendering read several templates
# from cache at once instead of one call per template.
#
# Templates in the collection not already cached are written to cache.
#
# Works great alongside individual template fragment caching.
# For instance if the template the collection renders is cached like:
#
# # notifications/_notification.html.erb
# <% cache notification do %>
# <%# ... %>
# <% end %>
#
# Any collection renders will find those cached templates when attempting
# to read multiple templates at once.
def cache(name = {}, options = {}, &block)
if controller.respond_to?(:perform_caching) && controller.perform_caching
name_options = options.slice(:skip_digest, :virtual_path)