Memcached Database Use

Jim Spath jspath at
Fri Jun 22 21:04:02 UTC 2007

Chris Miller wrote:
> Hi:
> I am new to memcached and I have a question about its use before I 
> implement it. I have a high traffic website written in PHP that is 
> currently using MySQL on the backend with query cache. The cache really 
> isn't working too well because the site is starting to have a massive 
> number of updates that invalidate the cache.
> My question is simple: How can memcached help me?
> I see how that by storing database results in memcached would be very 
> helpful, but how does memcached know when the result set in cache has 
> changed?
> In other words, if I go out to the cache and pull down a result set how 
> do I know if it's an accurate representation of the data?

Every time I update data in the database that affects one or more 
Memcached keys, I delete that Memcached key.  That way, when the data is 
needed by the application, a cache miss occurs, and the application 
fetches the data from the database, and repopulates the key.

It seems to work well enough for me...

- Jim

More information about the memcached mailing list