Skip to content

Instantly share code, notes, and snippets.

@coolsoftwaretyler
Last active February 7, 2020 03:50
Show Gist options
  • Save coolsoftwaretyler/1bdc269baadf6563a2df28d03cd0974b to your computer and use it in GitHub Desktop.
Save coolsoftwaretyler/1bdc269baadf6563a2df28d03cd0974b to your computer and use it in GitHub Desktop.

Revisions

  1. coolsoftwaretyler revised this gist Feb 7, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions sample_object.rb
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    class SampleObject < ApplicationRecord
    Rails.cache.fetch("#{cache_key_with_version}/components", expires_in: 12.hours) do
    def external_components
    # Some long running task that fetches "components"
    def external_components
    Rails.cache.fetch("#{cache_key_with_version}/components", expires_in: 12.hours) do
    # Some long running task that fetches "components"
    end
    end
    end
  2. coolsoftwaretyler revised this gist Feb 6, 2020. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion sample_view.html.erb
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@
    # https://guides.rubyonrails.org/caching_with_rails.html#shared-partial-caching
    <% @sample_object.external_components.each do |component| %>
    <% cache component do %>
    <%= render component %>
  3. coolsoftwaretyler created this gist Feb 6, 2020.
    7 changes: 7 additions & 0 deletions sample_object.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    class SampleObject < ApplicationRecord
    Rails.cache.fetch("#{cache_key_with_version}/components", expires_in: 12.hours) do
    def external_components
    # Some long running task that fetches "components"
    end
    end
    end
    6 changes: 6 additions & 0 deletions sample_view.html.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    # https://guides.rubyonrails.org/caching_with_rails.html#shared-partial-caching
    <% @sample_object.external_components.each do |component| %>
    <% cache component do %>
    <%= render component %>
    <% end %>
    <% end %>