namespace bids

Christopher Gillett cgillett at compete.com
Wed Feb 1 22:38:26 UTC 2006


> > Seems like namespaces are what we want here, and I think we'd be 
> > willing to pay for it.  As a pre-empt, the perl API does not really 
> > have name space support.  In my reading, all it does is 
> combine your 'namespace'
> > to keys, which as far as I can tell, aids little to our problem.

I would think the overhead in terms of both memory consumption and
compute overhead for implementing namespaces would turn memcache from
being a clean and quick solution to being something far bigger and
bulkier.  

We use namespaces within memcache here by prepending tags to keys prior
to commmiting them to the cache (for a non-web application).  This
eliminates the opportunity for unrelated applications trashing memcache
space being used by another application.  This doesn't allow flushing of
a particular namespace...just eliminates namespace pollution.

Our scheme is simple:     namespace.key

Implementing namespace flushing might not be a huge deal if you're
willing to create an anchor key to which is prepended ALL the keys held
in a given namespace.  Then you just get the list of keys from the
anchor key, and walk down the list deleting the appropriate keys.  This
is expensive from the perspective of adding/deleting keys requires
modifications to data referenced by another key.  Also, if the list of
keys is huge there are obvious issues.  You could always commit the key
names for a namespace to the database during key creation, so that
writing to the cache is slow but subsequent reads are fast.  Then
getting the list of keys becomes a query to the database and etc.

You could store "private" keys in a namespace by using a naming
convention (pythonically by __ or use your own scheme), like:

	namespace.__keys  = private list of keys in the namespace
      namespace.keys    = a public key named "keys" within the namespace

Then deleting the namespace becomes:
      
   deleteNameSpaceFromCache( namespace ):
	keysToNuke = get( "namespace.__keys" )
      for k in keysToNuke:
          delete( namespace+"."+k )
      delete( namespace+".__keys" )

Perhaps I'm under-thinking or over-simplifying, but isn't that the
essence of managing the name space from the perspective of deletion?

Chris




More information about the memcached mailing list