Add fails after delete

Michael Alan Dorman
Thu, 15 Jul 2004 08:42:27 -0400


I think this is a bug.

If you set a key, then delete it, then try to add it, it seems to me
it should add successfully.  However, as the attached script seems to
demonstrate, the add fails.

I haven't looked particulary hard at this---I only ran across it while
constructing a set of test cases for some libraries and being lazy at
the same time---re-running the same adds I had used to construct the
key I had just deleted.

I'm selling my soul again, I'm gaining the world -- David Sylvian

Content-Type: text/x-perl
Content-Disposition: inline;
Content-Description: Bug script?

#!/usr/bin/perl -w

use strict;
use warnings;
use Cache::Memcached;

my $cache = Cache::Memcached->new ({debug => 1, servers => [""]});

print "Setting key\n";
$cache->set ("testvalue", "some value");

print "Deleting key\n";
$cache->delete ("testvalue");

print "Retrieving key\n";
my $value = $cache->get ("testvalue") || "Not defined";
print "Value: $value\n";

print "Re-adding deleted key\n";
$value = $cache->add ("testvalue", 1) || "Not added";
print "Value: $value\n";