module ActionView::CollectionCaching
def fetch_or_cache_partial(cached_partials, template, order_by:)
If the partial is not already cached it will also be
corresponds to the first element in `rendered_partials`.
Order it so that the first empty cache element in `cached_partials`
for each element that was not found in the cache and store it as an array.
partial. An example is to render all results
This method expects a block that will return the rendered
otherwise `Hash#fetch` will take the value of its block.
it represents the rendered partial from the cache
`cached_partials` is a hash. If the value exists
all keys are passed in whether found already or not.
`order_by` is an enumerable object containing keys of the cache,
def fetch_or_cache_partial(cached_partials, template, order_by:) order_by.index_with do |cache_key| if content = cached_partials[cache_key] build_rendered_template(content, template) else yield.tap do |rendered_partial| collection_cache.write(cache_key, rendered_partial.body) end end end end