Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement 'noreply' option for update commands. (Tomash Brechko <toma…
…sh.brechko@gmail.com>) Commands add, set, replace, append, prepend, cas, delete, incr, decr, flush_all, verbosity can take last optional parameter, 'noreply', which instructs the server to not send the reply. Add benchmark script for noreply parameter. git-svn-id: http://code.sixapart.com/svn/memcached/trunk/server@708 b0b603af-a30f-0410-a34e-baf09ae79d0b
- Loading branch information
Showing
5 changed files
with
185 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#! /usr/bin/perl | ||
# | ||
use warnings; | ||
use strict; | ||
|
||
use IO::Socket::INET; | ||
|
||
use FindBin; | ||
|
||
@ARGV == 1 or @ARGV == 2 | ||
or die "Usage: $FindBin::Script HOST:PORT [COUNT]\n"; | ||
|
||
# Note that it's better to run the test over the wire, because for | ||
# localhost the task may become CPU bound. | ||
my $addr = $ARGV[0]; | ||
my $count = $ARGV[1] || 10_000; | ||
|
||
my $sock = IO::Socket::INET->new(PeerAddr => $addr, | ||
Timeout => 3); | ||
die "$!\n" unless $sock; | ||
|
||
|
||
# By running 'noreply' test first we also ensure there are no reply | ||
# packets left in the network. | ||
foreach my $noreply (1, 0) { | ||
use Time::HiRes qw(gettimeofday tv_interval); | ||
|
||
print "'noreply' is ", $noreply ? "enabled" : "disabled", ":\n"; | ||
my $param = $noreply ? 'noreply' : ''; | ||
my $start = [gettimeofday]; | ||
foreach (1 .. $count) { | ||
print $sock "add foo 0 0 1 $param\r\n1\r\n"; | ||
scalar<$sock> unless $noreply; | ||
print $sock "set foo 0 0 1 $param\r\n1\r\n"; | ||
scalar<$sock> unless $noreply; | ||
print $sock "replace foo 0 0 1 $param\r\n1\r\n"; | ||
scalar<$sock> unless $noreply; | ||
print $sock "append foo 0 0 1 $param\r\n1\r\n"; | ||
scalar<$sock> unless $noreply; | ||
print $sock "prepend foo 0 0 1 $param\r\n1\r\n"; | ||
scalar<$sock> unless $noreply; | ||
print $sock "incr foo 1 $param\r\n"; | ||
scalar<$sock> unless $noreply; | ||
print $sock "decr foo 1 $param\r\n"; | ||
scalar<$sock> unless $noreply; | ||
print $sock "delete foo $param\r\n"; | ||
scalar<$sock> unless $noreply; | ||
} | ||
my $end = [gettimeofday]; | ||
printf("update commands: %.2f secs\n\n", tv_interval($start, $end)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use Test::More tests => 10; | ||
use FindBin qw($Bin); | ||
use lib "$Bin/lib"; | ||
use MemcachedTest; | ||
|
||
|
||
my $server = new_memcached(); | ||
my $sock = $server->sock; | ||
|
||
|
||
# Test that commands can take 'noreply' parameter. | ||
print $sock "flush_all noreply\r\n"; | ||
print $sock "flush_all 0 noreply\r\n"; | ||
|
||
print $sock "verbosity 0 noreply\r\n"; | ||
|
||
print $sock "add noreply:foo 0 0 1 noreply\r\n1\r\n"; | ||
mem_get_is($sock, "noreply:foo", "1"); | ||
|
||
print $sock "set noreply:foo 0 0 1 noreply\r\n2\r\n"; | ||
mem_get_is($sock, "noreply:foo", "2"); | ||
|
||
print $sock "replace noreply:foo 0 0 1 noreply\r\n3\r\n"; | ||
mem_get_is($sock, "noreply:foo", "3"); | ||
|
||
print $sock "append noreply:foo 0 0 1 noreply\r\n4\r\n"; | ||
mem_get_is($sock, "noreply:foo", "34"); | ||
|
||
print $sock "prepend noreply:foo 0 0 1 noreply\r\n5\r\n"; | ||
my @result = mem_gets($sock, "noreply:foo"); | ||
ok($result[1] eq "534"); | ||
|
||
print $sock "cas noreply:foo 0 0 1 $result[0] noreply\r\n6\r\n"; | ||
mem_get_is($sock, "noreply:foo", "6"); | ||
|
||
print $sock "incr noreply:foo 3 noreply\r\n"; | ||
mem_get_is($sock, "noreply:foo", "9"); | ||
|
||
print $sock "decr noreply:foo 2 noreply\r\n"; | ||
mem_get_is($sock, "noreply:foo", "7"); | ||
|
||
print $sock "delete noreply:foo noreply\r\n"; | ||
mem_get_is($sock, "noreply:foo"); | ||
|
||
# Test that delete accepts both <time> and 'noreply'. | ||
print $sock "add noreply:foo 0 0 1 noreply\r\n1\r\n"; | ||
print $sock "delete noreply:foo 10 noreply\r\n"; | ||
print $sock "add noreply:foo 0 0 1 noreply\r\n1\r\n"; | ||
# undef result means we couldn't add an entry because the key is locked. | ||
mem_get_is($sock, "noreply:foo"); |