Permalink
Browse files

Allow a delete duration of 0.

This change covers the case where a reply is requested.  A separate,
more complicated change mixes in noreplys and 0 duration deletes.
  • Loading branch information...
1 parent 51d5489 commit 6436b96cc4d78fec0ceb839e2d1cdf455c7385bd @dustin dustin committed with dormando Nov 24, 2009
Showing with 22 additions and 1 deletion.
  1. +2 −1 memcached.c
  2. +20 −0 t/issue_108.t
View
@@ -2883,7 +2883,8 @@ static void process_delete_command(conn *c, token_t *tokens, const size_t ntoken
assert(c != NULL);
if (ntokens == 4) {
- if (!set_noreply_maybe(c, tokens, ntokens)) {
+ if (strcmp(tokens[KEY_TOKEN+1].value, "0") != 0
+ && !set_noreply_maybe(c, tokens, ntokens)) {
out_string(c, "CLIENT_ERROR bad command line format. "
"Usage: delete <key> [noreply]");
return;
View
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+
+use strict;
+use Test::More tests => 3;
+use FindBin qw($Bin);
+use lib "$Bin/lib";
+use MemcachedTest;
+
+my $server = new_memcached();
+my $sock = $server->sock;
+my $key = "del_key";
+
+print $sock "add $key 0 0 1\r\nx\r\n";
+is (scalar <$sock>, "STORED\r\n", "Added a key");
+
+print $sock "delete $key 0\r\n";
+is (scalar <$sock>, "DELETED\r\n", "Properly deleted with 0");
+
+print $sock "add $key 0 0 1\r\nx\r\n";
+is (scalar <$sock>, "STORED\r\n", "Added again a key");

0 comments on commit 6436b96

Please sign in to comment.