Page 1 of 1

memcache - when good to use

Posted: Sun Dec 16, 2007 10:52 am
by jmut
Hi,
I read stuff about memcache at http://www.danga.com/memcached/
and this look really good right...basically if you show some stats or something like stats.php?id=5 you cache this...and all users use the cache at same time...doing sql query once actually...
Only question is how do you tell memcache to update the cache... any tips and tricks on that...are you doing like refresh on each INSERT/UPDATE/DELETE on data that concerns the memcached thing?

Posted: Tue Dec 18, 2007 2:34 pm
by Ambush Commander
As long as the INSERT/UPDATE/DELETE operation knows about the correct key for the corresponding data in memcache, it can update the data itself.

Posted: Wed Dec 19, 2007 2:45 am
by dbevfat
You can invalidate the cache upon UPDATE/DELETE. Inserting records isn't really a problem, because there is no record in cache to invalidate.

Another way is to have a TTL (time to live) saved with each cache entry and requery the database every once in a while. This means the cache will contain some stale records at a given time but for many cases this isn't really a problem.

regards