You can always use a fragment caching approach and name your fragments
appropriately. Suppose its the index view of Projects...
def index
# massage your params tags into a usable form (implementation
# is left as an exercise for the reader - ''example'' in a
simple
# case, or some ugly string if you support multiple tags, and
# perhaps "base" if no tags exist in params)
@param_string = massage_tags(params[:tags])
# if you have it cached, don''t bother with the read
unless
Rails.cache.exist?(''views/project.index.''+@param_string)
@projects = Project.find(blah blah blah)
end
end
index.html.erb
<% cache(''project.index.''+@param_string) do %>
<% @projects.each do |project| %>
blah blah blah
<% end %>
<% end %>
Pagination will throw a wrinkle in this, as you''ll want a cache per
page
possibly, and create/edit/delete of an arbitrary project will
essentially invalidate all the caches for that model, unless you do some
logic I don''t even want to think about.
To save some processing time, you could cache just the index row for
each project and save that rendering time. If you display 30 projects on
the index form, and only 1 on the current page has changed (either via
addition, editing, or deletion), you''ll at least save the rendering on
the other 39... whether that is worthwhile depends on what data you are
showing.
YMMV
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.