Browsing projects by Tag(s)

Select a tag to browse associated projects and drill deeper into the tag cloud.

Showing page 1 of 1

In Rails, caching is one of those things that is made pretty easy, but can also be difficult when you want to do complex tasks with the caching -- such as expiring it. There are two ways with expire_fragment within the logic of your controllers or using an Observers. This plugin allows caching to ... [More] be expired on predefined time limit. The idea is that the caching takes cared of the expiration instead of writing conditions in the controller. I understand that it goes against the idea of why the caching mechanism does not have them now. To the plugin. Its an extension of cache method that has logic for the time limit. The method to use within views is called cache_timeout. The first argument of the method is the regular Hash/String of the cache key and the second argument is the timeout value (being a Time class value). Example usage: # This is last 5 minutes of posts from our forums: <%cache_timeout('forum_listing',5.minutes.from_now) do %> <% for post in @posts %> <%=post.title%> - by <%=post.author.username%> at <%=post.created_at>Unknown end tag for <%end%> <%end%> To enforce the timeout cache value within the controller don't use the read_fragment method -- unless really needed. The method that is provided to check that the timeout value has is expired is is_cache_expired?. The method takes the argument of the cache key. Example Usage within controller: def list if is_cache_expired?('forum_listing') @posts = Post.find(:all) end end [Less]

0
 
  0 reviews  |  0 users  |  0 current contributors
 
 
 
 

Creative Commons License Copyright © 2013 Black Duck Software, Inc. and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a Creative Commons Attribution 3.0 Unported License . Ohloh ® and the Ohloh logo are trademarks of Black Duck Software, Inc. in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.