How to delete lots of related keys at once

Perrin Harkins perrin at elem.com
Fri Aug 3 05:21:36 UTC 2007


On 8/2/07, Don MacAskill <don at smugmug.com> wrote:
> The way it invalides the cache is "if TABLE has changed in any way, get
> rid of any cache entries referencing this TABLE":
[...]
> You can, of course, do much better than this yourself if you goal is to
> cache certain SQL queries.

It's pretty hard to correctly determine which values a SQL statement
is going to modify without building your own RDBMS.  If you found a
way to do it for the general case, every database vendor would beat a
path to your door.  I'm sure you could do it for certain special cases
in a specific application though.

I think most people skip worrying about invalidation and opt to only
cache things that they can stand to have displaying incorrect data
until the cache expires.  Since computing a result from the source
data is slow (that's why you cache it), computing the results that are
affected by a change in the source data is also likely to be slow.

- Perrin


More information about the memcached mailing list