Skip to content

Multi fetch slower than no cache because of digest calculation #31

@pepesenaris

Description

@pepesenaris

I have the following scenario:
A partial rendered ( called _folder_results_table.html.erb) every 5 ms in a js view like this.
"<%= j(render('folder_results_table')) %>";
and within that partial I'm trying to render and cache a collection of hashes using this gem, like this:
<%=
render :partial => "result_asset", collection: @somegroups, as: :result,
locals: {group_name: group_name, group_name_to_id: group_name_to_id }
, cache: Proc.new { |item| [ item[:result][:asset], item[:job][:id], item[:name_collides] ] }
%>

The problem is that the digest for the parent cache is calculated in every item of the collection as given by the Rails log

Cache digest for folders/_folder_results_table.html: 44ebc3150678502edd950093fd618343
Cache digest for folders/result_asset.html: 46e854eaa29fb504ccd6786e10617704
... a 100 items later
Cache digest for folders/_folder_results_table.html: 44ebc3150678502edd950093fd618343
Cache digest for folders/result_asset.html: 46e854eaa29fb504ccd6786e10617704.

Why does the digests needs to be calculated in every item? This slowing the process some much that it's faster to not cache the result_asset partial at all. Is there any workaround, or I'm just stuck to not caching the collection which in real production data can have hundreds of elements and will be rendered every 5 sec or so (I know this is bad but right now can not be changed).

Best Regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions