Fabrizio Regini
2012-Nov-29 10:59 UTC
Proposal: faragment cache with :if / :unless conditions
Hi, I''m wondering if it would be a good idea to have fragment cache to allow options :if / :unless to determine whether or not to actually perform caching on the given block. It would actually be a good idea in my opinion right now, since I''m working on a piece of code that would benefit by this feature. The scenario is the following: I have a partial, which is conditionally requiring other partials inside. The first line of this partial starts with a `cache(key) do` declaration, but some of the nested partial can''t basically be cached due to the nature of the content. I could obviously wrap every nested partial call inside a cache for itself. This is technically not the same in terms of performance gain (not all computations inside the main partial would be cached) and it would probably be more clean to have something like this (trivialized): <%= cache(@model, unless: content_cachable?(@model)) do %> <% if @model.render_good? %> <%= render ''good_one'' %> <% else %> <%= render ''bad_one'' %> <% end %> ... other tens of similar conditions <% end %> This may reveal some bad partial design I''m facing, but I''m curious to know what you guys think about it. -f -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/LH35Qn-HOmEJ. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Steve Klabnik
2012-Nov-29 11:15 UTC
Re: Proposal: faragment cache with :if / :unless conditions
There is an open pull request for this: https://github.com/rails/rails/pull/5396 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Fabrizio Regini
2012-Nov-29 11:20 UTC
Re: Proposal: faragment cache with :if / :unless conditions
I searched issues for something similar but didn''t find it. Thanks! On Nov 29, 2012, at 12:15 PM, Steve Klabnik <steve@steveklabnik.com> wrote:> There is an open pull request for this: https://github.com/rails/rails/pull/5396 > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Fabrizio Regini
2012-Dec-03 12:10 UTC
Re: Proposal: faragment cache with :if / :unless conditions
Just for the records, there''s a new pull request here: https://github.com/rails/rails/pull/8371 On Thursday, November 29, 2012 12:15:10 PM UTC+1, Steve Klabnik wrote:> > There is an open pull request for this: > https://github.com/rails/rails/pull/5396 >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/7OSQ9Jv-8qkJ. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.