<?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>ninajansen.dk &#187; sweepers</title>
	<atom:link href="http://ninajansen.dk/category/sweepers/feed/" rel="self" type="application/rss+xml" />
	<link>http://ninajansen.dk</link>
	<description></description>
	<lastBuildDate>Thu, 23 Apr 2009 21:46:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Fragment cache expiry from background jobs is a hot mess</title>
		<link>http://ninajansen.dk/2008/06/11/fragment-cache-expiry-from-background-jobs-is-a-hot-mess/</link>
		<comments>http://ninajansen.dk/2008/06/11/fragment-cache-expiry-from-background-jobs-is-a-hot-mess/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 07:55:48 +0000</pubDate>
		<dc:creator>Nina Jansen</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[sweepers]]></category>

		<guid isPermaLink="false">http://ninajansen.dk/?p=39</guid>
		<description><![CDATA[In order to get a cache sweeper to actually do anything when it is triggered, it must be called from a controller, and that controller must be instantiated though a http request.
This is what I have learned from trying to expire fragment cache from background scripts in Ruby om Rails. It simply is not possible. [...]]]></description>
			<content:encoded><![CDATA[<p>In order to get a cache sweeper to actually do anything when it is triggered, it must be called from a controller, and that controller must be instantiated though a http request.</p>
<p>This is what I have learned from trying to expire fragment cache from background scripts in Ruby om Rails. It simply is not possible. If a controller is not instantiated when you hit the expire_fragment method<br />
(or any other cache sweeper method) you get a nil reply.</p>
<p>I understand why this decision has been made: Fragments are in views. Only the controller should deal with views. The controller is instantiated when it is requested by the web-server. Otherwise you break the MVC paradigm. Except that this mental model does not take into account the fact that<br />
every web-application (except the simplest ones) have stuff going on in the background. Long calculations are made by script so the user doesn&#8217;t have to wait while they are being finished. Stuff is done at a given time of day, like expiring old subscriptions. This is why we have BackgroundDRB and BJ. Background jobs need access to the fragment cache. If anyone who is really into rails could find a way to let background jobs do fragment cache things, I&#8217;d be very grateful.</p>
<p>For now, I have to periodically expire or reset all fragments because I know that background jobs periodically change the data used to generate them. Most inelegant and inefficient.</p>
<img src="http://ninajansen.dk/?ak_action=api_record_view&id=39&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://ninajansen.dk/2008/06/11/fragment-cache-expiry-from-background-jobs-is-a-hot-mess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cache sweepers in Rails, put them in app/models!</title>
		<link>http://ninajansen.dk/2008/05/14/cache-sweepers-in-rails-put-them-in-appmodels/</link>
		<comments>http://ninajansen.dk/2008/05/14/cache-sweepers-in-rails-put-them-in-appmodels/#comments</comments>
		<pubDate>Wed, 14 May 2008 15:41:50 +0000</pubDate>
		<dc:creator>Nina Jansen</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[sweepers]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://ninajansen.dk/?p=33</guid>
		<description><![CDATA[So i&#8217;ve been spending hours tracking this one down: I wanted to have cache sweepers in rails and followed the advice from railscasts and railsevny. Those tutorials tell you to put sweepers in an app/sweepers directory and add that directory to your load path. DON&#8217;T DO THAT. That simply did not work for me (using [...]]]></description>
			<content:encoded><![CDATA[<p>So i&#8217;ve been spending hours tracking this one down: I wanted to have cache sweepers in rails and followed the advice from <a href="http://railscasts.com/episodes/89">railscasts</a> and <a href="http://www.railsenvy.com/2007/2/28/rails-caching-tutorial">railsevny</a>. Those tutorials tell you to put sweepers in an app/sweepers directory and add that directory to your load path. DON&#8217;T DO THAT. That simply did not work for me (using rails 2.02). After banging my head against google for hours, I found out that sweeper simply has to go in app/models, MVC be dammed. If they are put there they get loaded, and you can add them as active record observers. If they are not put there rails won&#8217;t find them. I don&#8217;t know if this is a bug or a feature, but that is just the way it is.</p>
<img src="http://ninajansen.dk/?ak_action=api_record_view&id=33&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://ninajansen.dk/2008/05/14/cache-sweepers-in-rails-put-them-in-appmodels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
