<?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: memcached使用中的竞争条件</title>
	<atom:link href="http://www.robinlu.com/blog/archives/166/feed" rel="self" type="application/rss+xml" />
	<link>http://www.robinlu.com/blog/archives/166</link>
	<description>Robin Lu&#039;s weblog</description>
	<lastBuildDate>Thu, 02 Jun 2011 06:41:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
	<item>
		<title>By: 再谈rails缓存机制的问题 &#187; 石锅拌饭 &#124; 互联网 Mac &#38; 软件开发</title>
		<link>http://www.robinlu.com/blog/archives/166/comment-page-1#comment-41322</link>
		<dc:creator>再谈rails缓存机制的问题 &#187; 石锅拌饭 &#124; 互联网 Mac &#38; 软件开发</dc:creator>
		<pubDate>Thu, 31 Jan 2008 11:54:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.robinlu.com/blog/archives/166#comment-41322</guid>
		<description>[...] 我们首先怀疑是出现了类似&#8220;memcached使用中的竞争条件&#8221;中提到的问题，于是在缓存清除和创建的地方分别添加日志。结果很让我们吃惊，在after_save里用find取出的数据的确是新的，创建缓存的时间明显晚于after_save被调用的时间，但用同样的方法取出的数据却是旧的。 [...]</description>
		<content:encoded><![CDATA[<p>[...] 我们首先怀疑是出现了类似&#8220;memcached使用中的竞争条件&#8221;中提到的问题，于是在缓存清除和创建的地方分别添加日志。结果很让我们吃惊，在after_save里用find取出的数据的确是新的，创建缓存的时间明显晚于after_save被调用的时间，但用同样的方法取出的数据却是旧的。 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin Lu</title>
		<link>http://www.robinlu.com/blog/archives/166/comment-page-1#comment-37122</link>
		<dc:creator>Robin Lu</dc:creator>
		<pubDate>Thu, 29 Nov 2007 06:45:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.robinlu.com/blog/archives/166#comment-37122</guid>
		<description>对于你上面提到的情况，如果数据更新相对频繁，对展示准确性要求不是十分严格的情况下，可以通过缩短缓存过期时间来缓解这个问题。如果对数据一致性要求非常严格，可以配合cas方法来解决。cas方法为数据添加了“版本”信息，能解决更多的竞争问题。

目前ruby的memcached-client没有实现cas方法，需要自己实现。</description>
		<content:encoded><![CDATA[<p>对于你上面提到的情况，如果数据更新相对频繁，对展示准确性要求不是十分严格的情况下，可以通过缩短缓存过期时间来缓解这个问题。如果对数据一致性要求非常严格，可以配合cas方法来解决。cas方法为数据添加了“版本”信息，能解决更多的竞争问题。</p>
<p>目前ruby的memcached-client没有实现cas方法，需要自己实现。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adou</title>
		<link>http://www.robinlu.com/blog/archives/166/comment-page-1#comment-37118</link>
		<dc:creator>adou</dc:creator>
		<pubDate>Thu, 29 Nov 2007 05:12:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.robinlu.com/blog/archives/166#comment-37118</guid>
		<description>设置缓存的时候 数据是从master而不是slave数据库取 基本能保证数据是新的 在取出数据到设置缓存这一瞬间如果有并发的写 确实会有问题</description>
		<content:encoded><![CDATA[<p>设置缓存的时候 数据是从master而不是slave数据库取 基本能保证数据是新的 在取出数据到设置缓存这一瞬间如果有并发的写 确实会有问题</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adou</title>
		<link>http://www.robinlu.com/blog/archives/166/comment-page-1#comment-37111</link>
		<dc:creator>adou</dc:creator>
		<pubDate>Thu, 29 Nov 2007 04:06:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.robinlu.com/blog/archives/166#comment-37111</guid>
		<description>嗯 有竞争的时候确实是会有问题 但是可能被查询到的数据有上亿条 并且有各种组合 不可能把它们全部放进缓存 现在只是当个别被访问到的时候才进行缓存 然后设置一个过期时间 如果不在取数据的时候生成缓存 有什么好方法吗 :) 不吝赐教</description>
		<content:encoded><![CDATA[<p>嗯 有竞争的时候确实是会有问题 但是可能被查询到的数据有上亿条 并且有各种组合 不可能把它们全部放进缓存 现在只是当个别被访问到的时候才进行缓存 然后设置一个过期时间 如果不在取数据的时候生成缓存 有什么好方法吗 <img src='http://www.robinlu.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  不吝赐教</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin Lu</title>
		<link>http://www.robinlu.com/blog/archives/166/comment-page-1#comment-37098</link>
		<dc:creator>Robin Lu</dc:creator>
		<pubDate>Thu, 29 Nov 2007 00:42:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.robinlu.com/blog/archives/166#comment-37098</guid>
		<description>楼上，请仔细阅读我的原文，你就能理解为什么不能在取数据的时候再生成。
直接把set改成add是不能解决问题的，除非你在add的时候能够确认你使用的是新数据，否则可能会把事情搞得更糟糕。</description>
		<content:encoded><![CDATA[<p>楼上，请仔细阅读我的原文，你就能理解为什么不能在取数据的时候再生成。<br />
直接把set改成add是不能解决问题的，除非你在add的时候能够确认你使用的是新数据，否则可能会把事情搞得更糟糕。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adou</title>
		<link>http://www.robinlu.com/blog/archives/166/comment-page-1#comment-37078</link>
		<dc:creator>adou</dc:creator>
		<pubDate>Wed, 28 Nov 2007 16:37:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.robinlu.com/blog/archives/166#comment-37078</guid>
		<description>大多数情况把取数据时候生成缓存的set改成add应该就够了

修改或删除数据时 如果需要set的话 又得去获取一次完整的缓存数据 直接delete 等取数据的时候再生成好了

这样应该会简单些

当然如果能很方便得到完整的需要缓存的数据 在修改后直接set更好 那样可以直接让下次被访问时就直接从缓存取数据</description>
		<content:encoded><![CDATA[<p>大多数情况把取数据时候生成缓存的set改成add应该就够了</p>
<p>修改或删除数据时 如果需要set的话 又得去获取一次完整的缓存数据 直接delete 等取数据的时候再生成好了</p>
<p>这样应该会简单些</p>
<p>当然如果能很方便得到完整的需要缓存的数据 在修改后直接set更好 那样可以直接让下次被访问时就直接从缓存取数据</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 好文推荐 程字(20071112)号 &#187; 不合格的程序员</title>
		<link>http://www.robinlu.com/blog/archives/166/comment-page-1#comment-35127</link>
		<dc:creator>好文推荐 程字(20071112)号 &#187; 不合格的程序员</dc:creator>
		<pubDate>Mon, 12 Nov 2007 12:20:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.robinlu.com/blog/archives/166#comment-35127</guid>
		<description>[...] - memcached使用中的竞争条件 » 石锅拌饭 &#124; 互联网 Mac &amp; 软件开发，累计共2个收藏 ror中解决memcached缓存无法及时更新的问题。cas(clear and set) [...]</description>
		<content:encoded><![CDATA[<p>[...] &#8211; memcached使用中的竞争条件 » 石锅拌饭 | 互联网 Mac &#38; 软件开发，累计共2个收藏 ror中解决memcached缓存无法及时更新的问题。cas(clear and set) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Caiwangqin</title>
		<link>http://www.robinlu.com/blog/archives/166/comment-page-1#comment-33131</link>
		<dc:creator>Caiwangqin</dc:creator>
		<pubDate>Sat, 27 Oct 2007 09:43:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.robinlu.com/blog/archives/166#comment-33131</guid>
		<description>Thanks for sharing.</description>
		<content:encoded><![CDATA[<p>Thanks for sharing.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

