invalidation by namespace Re: Listing all keys on a server: why?

Brian Moon brianm at dealnews.com
Fri Jul 28 09:02:30 UTC 2006


(disclaimer: I am at OSCON and its 1AM.  That means I was drunk when I
wrote this reply)

> 1. key_salt is effectively a namespace. The point of
> namespace is to allow the whole 'namespace' to expire
> at once and quietly. 

Yes

> 2. Every time you need to access the key that belongs
> to key_salt namespace (being that get or set) - you
> have to fetch the key_salt from memcached (to
> construct the 'full name') - that means that you have
> one extra request to memcached. No big deal, but still
> ;-)

Yes

> 3. key_salt is stored in memcached forever. (there is
> no official way in memcached to guarantee that,
> because strictly speaking expiration==0 does not
> guarantee that the key will got get pushed out in
> 'need more RAM' situation when the item had slided to
> the end of LRU list). However, in the real life
> (because it would be accessed frequently) it is
> unlikely for key_salt to slide down all the way to the
> end of LRU list, so it is kinda safe to assume that it
> will be there 'forever', but still ;-)

Yes, yes and yes (I think I counted right).

ok, I did not follow the rest of this stuff so I will skip it.

I should clearly say that I did not think of this.  Someone else posted
this idea to this list some time ago.  I tried to find it in the archive
so that I could properly give them credit, but alas, my searching did
not work.

I do have in mind some PHP libs that would support n amount of
namespaces.  If I get a wild hair, I will put them together and publish
them.  Basically it would just use func_get_args() to allow you to pass
as many namespaces (or tags you might say) to a get/set call.  You could
then blow away anything that uses any of those tags.  We do this with
our raw query cache.  There is a query cache salt and per site salt.  We
can therefore kill all query cache or just query cache for a given site.
  In our case, we create a "mysql_{pub_id}" salt.  You could instead
just have a "pub_{pub_id}" salt and effectively kill all cache for a
given pub.  We don't do that.  We built a little script that has drop
downs that lets us do only parts.  I just go through the drop downs and
kill what is needed. (ok, I am drunk and rambling.  I will stop.  OSCON
rocks!!!!!!!!).

-- 

Brian Moon
-------------
http://dealnews.com/
Its good to be cheap =)



More information about the memcached mailing list