Automatically maintaining cache consistency

Mohammad J desertland at
Wed Aug 29 20:58:28 UTC 2007

The memcached FAQ says you should "Update memcache as your data updates" (,
but doesn't really provide any good ways for doing so.

On larger websites, I've found it nearly impossible to keep track of all the
cache keys and where they're set.  When multiple people are working on a
project, setting keys and manipulating data, it becomes quite a challenge to
invalidate the appropriate cache elements when the underlying data changes.

At the worldcomp '07 conference, there was a method presented that is
available online at  In short, by defining
dependency information in your source code whenever you set a cache element,
you can analyze the source code at deploy-time to identify all the
dependencies.  Then, whenever a SQL query is issued to update the underlying
data, if necessary, all the appropriate cache elements will also be
invalidated.  For simple applications it's nothing special, but if you have
a big application, this method is quite a nice way to keep your cache
up-to-date with your database.
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the memcached mailing list