namespace bids

Veres Lajos vlajos at ludens.elte.hu
Fri Feb 3 21:46:17 UTC 2006


Hello,

A naive implementation idea:

function (set/add/replace)_withnamespace($namespace,$key,$otherargs){
 	real_function($key,$otherargs);
 	$tmp=increment($namespace);
 	replace($namespace.$tmp,$realkey);
}

function purge_namespace($namespace){
 	while($tmp=decrement($namespace)){
 		delete(get($namespace.$tmp));
 	}
}

This can be done client side.

The basic idea to store namespace releated keys in an array, but real 
arrays cant be useable, because get-addentry-set isnt atomic.

In this implementation (like thing) we use the atomicity of increment.
And we try to mimic the array like behaviour.

I think some initialisation is needed.
"Memcache::increment() does not  create an item if it didn't exist."

And this can produce strange things if server structure changes.
$namespace, and $namespace[0-9]+ like keys has important role.

If the releated server(s) fails, then the namespace will be in undefined 
state.

On Fri, 3 Feb 2006, Cahill, Earl wrote:

>> Our scheme is simple:     namespace.key
>
> We do something similar.
>
>> Then you just get the list of keys from the
>> anchor key, and walk down the list deleting the appropriate keys.
>
> I don't know how to get a list of all the keys.  I tried doing
>
> stats slabs
>
>    foreach my $slab (@$slabs) {
>        my $slab_dump = $mc->_oneline($sock, "stats cachedump
> $slab\r\n");
>        while($slab_dump =~ /^ITEM\s+(\S+)/mg) {
>            $ref->{$1} = $mc->get($1);
>        }
>    }
>
> But I guess the cachedump doesn't return everything on the slab.  With
> the code above I wanted to see the values, so I just did a get.  If
> someone has a way to walk all the keys, then yeah, that would pretty
> well solve my 'fred' problem, where changes only happen every few weeks,
> and I am ok if the process takes a few minutes to complete.
>
> Earl
>

-- 
Veres Lajos
vlajos at ludens.elte.hu
+36 20 438 5909


More information about the memcached mailing list