<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jabbering Giraffe &#187; caching</title>
	<atom:link href="http://happygiraffe.net/blog/tag/caching/feed/" rel="self" type="application/rss+xml" />
	<link>http://happygiraffe.net/blog</link>
	<description></description>
	<lastBuildDate>Tue, 07 Feb 2012 20:49:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>TimedFileStore Plugin 0.1</title>
		<link>http://happygiraffe.net/blog/2006/05/08/timedfilestore-plugin-0-1/</link>
		<comments>http://happygiraffe.net/blog/2006/05/08/timedfilestore-plugin-0-1/#comments</comments>
		<pubDate>Mon, 08 May 2006 21:56:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2006/05/08/timedfilestore-plugin-0-1/</guid>
		<description><![CDATA[My first rails plugin: timed_file_store is now available. It lets you expire fragments based upon the time of the cached file. It&#8217;s fairly easy to use; just bung this into config/environments.rb: ActionController::Base.fragment_cache_store = TimedFileStore.new("#{RAILS_ROOT}/tmp/cache", :atime =&#62; 15.minutes) And now any &#8230; <a href="http://happygiraffe.net/blog/2006/05/08/timedfilestore-plugin-0-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My first rails plugin: <a href="http://happygiraffe.net/svn/public/timed_file_store/tags/rel_0-1/">timed_file_store</a> is now available.  It lets you expire fragments based upon the time of the cached file.  It&#8217;s fairly easy to use; just bung this into <code>config/environments.rb</code>:</p>
<pre>
  ActionController::Base.fragment_cache_store =
    TimedFileStore.new("#{RAILS_ROOT}/tmp/cache", :atime =&gt; 15.minutes)
</pre>
<p>And now any fragments which haven&#8217;t been accessed in the last 15 minutes will be removed the next time that they&#8217;re accessed.</p>
<p>This is rather coarse&#8212;it applies to all fragments.  But it&#8217;s also pretty simple and does what I need for now.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/05/08/timedfilestore-plugin-0-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Fragment Cache Expiry</title>
		<link>http://happygiraffe.net/blog/2006/05/07/rails-fragment-cache-expiry/</link>
		<comments>http://happygiraffe.net/blog/2006/05/07/rails-fragment-cache-expiry/#comments</comments>
		<pubDate>Sun, 07 May 2006 22:20:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2006/05/07/rails-fragment-cache-expiry/</guid>
		<description><![CDATA[I&#8217;ve been looking at Rails&#8217; fragment caching recently. I want to cache some stuff in my view that&#8217;s more or less independent of my model (eg: output from some slow command like top). That&#8217;s fine, and easily done. &#60;% cache &#8230; <a href="http://happygiraffe.net/blog/2006/05/07/rails-fragment-cache-expiry/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been looking at Rails&#8217; <a href="http://api.rubyonrails.org/classes/ActionController/Caching/Fragments.html">fragment caching</a> recently.  I want to cache some stuff in my view that&#8217;s more or less independent of my model (eg: output from some slow command like top).  That&#8217;s fine, and easily done.</p>
<pre>
  &lt;% cache do %&gt;
    &lt;%=h `top` %&gt;
  &lt;% end %&gt;
</pre>
<p>The trouble is expiry (as it always is with caching).  By default, Rails offers you things like <code>expire_fragment</code> and <a href="http://api.rubyonrails.org/classes/ActionController/Caching/Sweeping.html">Sweeping</a>, but these are very much tied in to the Model classes.</p>
<p>What I really need is to know the timestamp of each entry in the cache, so I can make judgements based on that.  Unfortunately, at present, ActionController seems to treat each cache entry as little more than a blob of data.  I need to store metadata with it, like when it was last accessed and when it was put in the cache.  I&#8217;m not sure that I can do that in the current framework.</p>
<p>It looks like I&#8217;m not the only one who wants this: see also <a href="http://blog.tourb.us/archives/time-based-cache/">Time-based fragment caching in Rails</a>.  I&#8217;m not 100% sure I like that solution, but it does look like it would work.  Perhaps I&#8217;m too institutionalized towards cron?  I&#8217;d definitely rather avoid using cron if I can possibly help it (lesson from work: system dependencies are <strong>bad</strong>).</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/05/07/rails-fragment-cache-expiry/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

