Deletes Are Driving Me Crazy

Cahill, Earl ecahill at corp.untd.com
Wed Jan 11 21:15:41 UTC 2006


I saw this same behavior a little while ago and I downloaded version
1.1.12.  My old version was installed via apt-get and getting the new
version running took a little doing.  Seems like apt kept a hook or two
around and I had to clear a few things out.  I don't want to sound like
a dork, but I am wondering if possibly the same thing is happening for
you?

With 1.1.11, deletes would take sometimes four or five seconds to
happen, with 1.1.12, I could add/delete several thousand times a second.
I was using the perl client.

Earl

-----Original Message-----
From: memcached-bounces at lists.danga.com
[mailto:memcached-bounces at lists.danga.com] On Behalf Of Skylos
Sent: Wednesday, January 11, 2006 12:01 PM
To: Matthew Glubb
Cc: memcached at lists.danga.com
Subject: Re: Deletes Are Driving Me Crazy

I dunno the architecture of your application...

But were I doing this in a straightforward way... in a perlish sort of
way...

$mc->delete($key,$val);
unless ($mc->add($key,$val2)) {
    $mc->replace($key, $val2);
}

But, if it was something on the order of

Destroy objectinstanceA
Create objectinstanceB

where the destructor of A deletes, and the creator of B adds, it might
be alot harder to do that.

In that case, I could see a serious problem regarding this behavior.

Then I start to be hacky.

I'll do something like

sub DESTROY {
    $mc->add($key . "-okaytoreplace", 1) unless ($mc->incr($key .
"-okaytoreplace"));
    $mc->delete($key);
}

sub new {
    unless ($mc->add($key, $value)) {
        unless ($mc->decr($key . "-okaytoreplace")) {
            $mc->replace($key, $value);
        } else {
            error("add failed no overwrite");
        }
    }
}

But... maybe that not work for you.  I dunno.

Just a thought,

Skylos

PS - pardon my perlisms.


More information about the memcached mailing list