<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	>
<channel>
	<title>Comments on: 再谈rails缓存机制的问题</title>
	<atom:link href="http://www.robinlu.com/blog/archives/184/feed" rel="self" type="application/rss+xml" />
	<link>http://www.robinlu.com/blog/archives/184</link>
	<description>Robin Lu's weblog</description>
	<pubDate>Mon, 06 Sep 2010 13:02:15 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Robin Lu</title>
		<link>http://www.robinlu.com/blog/archives/184/comment-page-1#comment-44309</link>
		<dc:creator>Robin Lu</dc:creator>
		<pubDate>Wed, 05 Mar 2008 03:34:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.robinlu.com/blog/archives/184#comment-44309</guid>
		<description>这里讨论的是built-in transaction，目的是把可预知的transaction先为你加上，能省一点事就省一点事，也算符合DRY的原则。的确更多的transaction应该是controller里控制的，但情况就千变万化了，做成built-in恐怕更不方便更找骂。</description>
		<content:encoded><![CDATA[<p>这里讨论的是built-in transaction，目的是把可预知的transaction先为你加上，能省一点事就省一点事，也算符合DRY的原则。的确更多的transaction应该是controller里控制的，但情况就千变万化了，做成built-in恐怕更不方便更找骂。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 老王</title>
		<link>http://www.robinlu.com/blog/archives/184/comment-page-1#comment-44296</link>
		<dc:creator>老王</dc:creator>
		<pubDate>Wed, 05 Mar 2008 02:03:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.robinlu.com/blog/archives/184#comment-44296</guid>
		<description>我觉得Rails本身的事务处理就是问题的，在ActiveRecord对象上加入事务功能不管怎么说也不对吧，正确的位置应该是Controller的Action上，因为它勾画了事务的自然边界。</description>
		<content:encoded><![CDATA[<p>我觉得Rails本身的事务处理就是问题的，在ActiveRecord对象上加入事务功能不管怎么说也不对吧，正确的位置应该是Controller的Action上，因为它勾画了事务的自然边界。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 金色葡萄</title>
		<link>http://www.robinlu.com/blog/archives/184/comment-page-1#comment-43213</link>
		<dc:creator>金色葡萄</dc:creator>
		<pubDate>Wed, 20 Feb 2008 16:03:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.robinlu.com/blog/archives/184#comment-43213</guid>
		<description>这是一则公益spam：
正月十五是合法燃放烟花爆竹的最后一天，这一天人们会把所有留存的烟花爆竹全部放掉。
请务必注意安全，最好使用护目镜防护！！
往年在正月十五这一天受伤的人比年三十还多。
打扰了，请在正月十六删除吧。</description>
		<content:encoded><![CDATA[<p>这是一则公益spam：<br />
正月十五是合法燃放烟花爆竹的最后一天，这一天人们会把所有留存的烟花爆竹全部放掉。<br />
请务必注意安全，最好使用护目镜防护！！<br />
往年在正月十五这一天受伤的人比年三十还多。<br />
打扰了，请在正月十六删除吧。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin Lu</title>
		<link>http://www.robinlu.com/blog/archives/184/comment-page-1#comment-41683</link>
		<dc:creator>Robin Lu</dc:creator>
		<pubDate>Mon, 04 Feb 2008 06:16:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.robinlu.com/blog/archives/184#comment-41683</guid>
		<description>hideto,我google了一下，搜到这个after_commit, http://elimiller.blogspot.com/2007/06/proper-cache-expiry-with-aftercommit.html, 这个是你们在用的么？
从代码上看，他用的是我文章里提到的第一种方案，没有考虑到transaction嵌套，是有问题的。</description>
		<content:encoded><![CDATA[<p>hideto,我google了一下，搜到这个after_commit, <a href="http://elimiller.blogspot.com/2007/06/proper-cache-expiry-with-aftercommit.html" rel="nofollow">http://elimiller.blogspot.com/2007/06/proper-cache-expiry-with-aftercommit.html</a>, 这个是你们在用的么？<br />
从代码上看，他用的是我文章里提到的第一种方案，没有考虑到transaction嵌套，是有问题的。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hideto</title>
		<link>http://www.robinlu.com/blog/archives/184/comment-page-1#comment-41643</link>
		<dc:creator>hideto</dc:creator>
		<pubDate>Sun, 03 Feb 2008 16:43:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.robinlu.com/blog/archives/184#comment-41643</guid>
		<description>最近我们开发项目时也遇到一个场景和这个非常类似
我们需要在after_save中做一些操作，但是希望在事务提交后执行

后来发现有段after_commit代码可以实现这个目标呵呵</description>
		<content:encoded><![CDATA[<p>最近我们开发项目时也遇到一个场景和这个非常类似<br />
我们需要在after_save中做一些操作，但是希望在事务提交后执行</p>
<p>后来发现有段after_commit代码可以实现这个目标呵呵</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin Lu</title>
		<link>http://www.robinlu.com/blog/archives/184/comment-page-1#comment-41426</link>
		<dc:creator>Robin Lu</dc:creator>
		<pubDate>Fri, 01 Feb 2008 13:31:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.robinlu.com/blog/archives/184#comment-41426</guid>
		<description>你提到的方法的确可以做为一种workaround，但这样的workaround可能有这样一些个问题：

一是需要自己实现一套修改更新的互斥机制。memcached已经有这样的互斥机制，而rails cache没有。

二是它仍然无法保证ACID，当数据保存在更新缓存后出错，然后rollback了，数据并没有真的更新，而缓存却变成别的内容了，你还需要hook rollback_db_transaction，仍然需要记录曾经更新的内容，可能比把更新和删除缓存的操作拿出transaction更复杂。</description>
		<content:encoded><![CDATA[<p>你提到的方法的确可以做为一种workaround，但这样的workaround可能有这样一些个问题：</p>
<p>一是需要自己实现一套修改更新的互斥机制。memcached已经有这样的互斥机制，而rails cache没有。</p>
<p>二是它仍然无法保证ACID，当数据保存在更新缓存后出错，然后rollback了，数据并没有真的更新，而缓存却变成别的内容了，你还需要hook rollback_db_transaction，仍然需要记录曾经更新的内容，可能比把更新和删除缓存的操作拿出transaction更复杂。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hideto</title>
		<link>http://www.robinlu.com/blog/archives/184/comment-page-1#comment-41406</link>
		<dc:creator>hideto</dc:creator>
		<pubDate>Fri, 01 Feb 2008 08:53:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.robinlu.com/blog/archives/184#comment-41406</guid>
		<description>实际上和你在“memcached使用中的竞争条件中所说的一样”，一直不使用Cache.delete清空缓存而是在数据更新后使用Cache.put直接更新缓存即可，这样即使ActiveRecord的transaction包容了不该放在transaction里的东西(这个东西由“清空缓存”变成了“更新缓存”)也没关系啊呵呵</description>
		<content:encoded><![CDATA[<p>实际上和你在“memcached使用中的竞争条件中所说的一样”，一直不使用Cache.delete清空缓存而是在数据更新后使用Cache.put直接更新缓存即可，这样即使ActiveRecord的transaction包容了不该放在transaction里的东西(这个东西由“清空缓存”变成了“更新缓存”)也没关系啊呵呵</p>
]]></content:encoded>
	</item>
</channel>
</rss>
