0

below is the scenario: here is a access statistic system, just like Blogger's overviewstats function. Statistic data is stored persistent in database(like MySQL), while using a key-value cache(now is memcache) to cache the access counts, each access only update the value in cache.

Now the question is how to synch back the latest count value to database? A normal solution is to write back after some interval, but memcache will discard items when there is no enough spaces, some updates may lost. so I think a better solution is if memcache can send a message(like JMS) when discarding an item, and then i can synch that item to database. It seems that memcache does not provide this function, is there any other key-value cache can do this? Or is there any better solutions?

4

1 回答 1

0

Memcached 是一个缓存,所以你需要将它作为一个缓存来使用。当您更新 memcached 中的访问计数时,您还应该将更新排入队列,以便它们可以异步写入数据库。这样,可以从数据库中重新加载超出缓存的计数。

我喜欢 memcached 排队即将被丢弃的项目的想法,但由于性能考虑,它可能不会在主项目中发生。

于 2012-07-30T13:56:54.167 回答