<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -7,84 +7,73 @@ use FindBin qw($Bin);
 use lib &quot;$Bin/lib&quot;;
 use MemcachedTest;
 
-ok(&quot;foo&quot;, &quot;foo&quot;);
-=temporarily_disable
 my $server = new_memcached();
-
 ok($server, &quot;started the server&quot;);
 
-# Based almost 100% off testClient.py which is Copyright (c) 2007  Dustin Sallings &lt;dustin@spy.net&gt;
+# Based almost 100% off testClient.py which is:
+# Copyright (c) 2007  Dustin Sallings &lt;dustin@spy.net&gt;
 
 # Command constants
-use constant CMD_GET     =&gt; 0;
-use constant CMD_SET     =&gt; 1;
-use constant CMD_ADD     =&gt; 2;
-use constant CMD_REPLACE =&gt; 3;
-use constant CMD_DELETE  =&gt; 4;
-use constant CMD_INCR    =&gt; 5;
-use constant CMD_DECR    =&gt; 6;
-use constant CMD_QUIT    =&gt; 7;
-use constant CMD_FLUSH   =&gt; 8;
-use constant CMD_GETQ    =&gt; 9;
-use constant CMD_NOOP    =&gt; 10;
-use constant CMD_VERSION =&gt; 11;
-
-# CAS, Flags, expiration
-use constant SET_PKT_FMT =&gt; &quot;NNNN&quot;;
-
-# Flags, expiration, id
-use constant CAS_PKT_FMT =&gt; &quot;NNNN&quot;;
-
-# How long until the deletion takes effect.
-use constant DEL_PKT_FMT =&gt; &quot;N&quot;;
-
-# amount, initial value, expiration
+use constant CMD_GET     =&gt; 0x00;
+use constant CMD_SET     =&gt; 0x01;
+use constant CMD_ADD     =&gt; 0x02;
+use constant CMD_REPLACE =&gt; 0x03;
+use constant CMD_DELETE  =&gt; 0x04;
+use constant CMD_INCR    =&gt; 0x05;
+use constant CMD_DECR    =&gt; 0x06;
+use constant CMD_QUIT    =&gt; 0x07;
+use constant CMD_FLUSH   =&gt; 0x08;
+use constant CMD_GETQ    =&gt; 0x09;
+use constant CMD_NOOP    =&gt; 0x0A;
+use constant CMD_VERSION =&gt; 0x0B;
+use constant CMD_GETK    =&gt; 0x0C;
+use constant CMD_GETKQ   =&gt; 0x0D;
+use constant CMD_APPEND  =&gt; 0x0E;
+use constant CMD_PREPEND =&gt; 0x0F;
+
+# REQ and RES formats are divided even though they currently share 
+# the same format, since they _could_ differ in the future.
+use constant REQ_PKT_FMT      =&gt; &quot;CCnCCnNNNN&quot;;
+use constant RES_PKT_FMT      =&gt; &quot;CCnCCnNNNN&quot;;
 use constant INCRDECR_PKT_FMT =&gt; &quot;NNNNN&quot;;
-
-use constant REQ_MAGIC_BYTE =&gt; 0x80;
-use constant RES_MAGIC_BYTE =&gt; 0x81;
-
-use constant PKT_FMT =&gt; &quot;CCnCxxxNN&quot;;
-
-#min recv packet size
-use constant MIN_RECV_PACKET =&gt; length(pack(PKT_FMT));
+use constant MIN_RECV_BYTES   =&gt; length(pack(RES_PKT_FMT));
+use constant REQ_MAGIC        =&gt; 0x80;
+use constant RES_MAGIC        =&gt; 0x81;
 
 my $mc = MC::Client-&gt;new;
+
 my $check = sub {
-	my ($key, $orig_flags, $orig_value) = @_;
-	my ($flags, $value) = $mc-&gt;get($key);
-	is($flags, $orig_flags, &quot;Flags is set properly&quot;);
-	is($value, $orig_value, &quot;Value is set properly&quot;);
+    my ($key, $orig_flags, $orig_val) = @_;
+    my ($flags, $val, $cas) = $mc-&gt;get($key);
+    is($flags, $orig_flags, &quot;Flags is set properly&quot;);
 };
 
 my $set = sub {
-	my ($key, $exp, $orig_flags, $orig_value) = @_;
-	$mc-&gt;set($key, $exp, $orig_flags, $orig_value);
-	$check-&gt;($key, $orig_flags, $orig_value);
+    my ($key, $exp, $orig_flags, $orig_value) = @_;
+    $mc-&gt;set($key, $orig_value, $orig_flags, $exp);
+    $check-&gt;($key, $orig_flags, $orig_value);
 };
 
 my $empty = sub {
-	my $key = shift;
-	my $rv =()= eval { $mc-&gt;get($key) };
-	is($rv, 0, &quot;Didn't get a result from get&quot;);
-	ok($@-&gt;not_found, &quot;We got a not found error when we expected one&quot;);
+    my $key = shift;
+    my $rv =()= eval { $mc-&gt;get($key) };
+    is($rv, 0, &quot;Didn't get a result from get&quot;);
+    ok($@-&gt;not_found, &quot;We got a not found error when we expected one&quot;);
 };
 
 my $delete = sub {
-	my ($key, $when) = @_;
-	$mc-&gt;delete($key, $when);
-	$empty-&gt;($key);
+    my ($key, $when) = @_;
+    $mc-&gt;delete($key, $when);
+    $empty-&gt;($key);
 };
 
+diag &quot;Test Version&quot;;
+my $v = $mc-&gt;version;
+ok(defined $v &amp;&amp; length($v), &quot;Proper version: $v&quot;);
+
 diag &quot;Flushing...&quot;;
 $mc-&gt;flush;
 
-{
-	diag &quot;Test Version&quot;;
-	my $v = $mc-&gt;version;
-	ok(defined $v &amp;&amp; length($v), &quot;Proper version: $v&quot;);
-}
-
 diag &quot;Noop&quot;;
 $mc-&gt;noop;
 
@@ -102,58 +91,43 @@ $empty-&gt;('x');
 $empty-&gt;('y');
 
 {
-	diag &quot;Reservation delete&quot;;
-	$set-&gt;('y', 5, 19, &quot;someothervalue&quot;);
-	$delete-&gt;('y', 1);
-	my $rv =()= eval { $mc-&gt;add('y', 5, 19, &quot;yetanothervalue&quot;) };
-	is($rv, 0, &quot;Add didn't return anything&quot;);
-	ok($@-&gt;exists, &quot;We got an exists error like we expected&quot;);
-	sleep 2;
-	$mc-&gt;add('y', 5, 19, &quot;wibblevalue&quot;);
+    diag &quot;Add&quot;;
+    $empty-&gt;('i');
+    $mc-&gt;add('i', 'ex', 5, 10);
+    $check-&gt;('i', 5, &quot;ex&quot;);
+
+    my $rv =()= eval { $mc-&gt;add('i', &quot;ex2&quot;, 10, 5) };
+    is($rv, 0, &quot;Add didn't return anything&quot;);
+    ok($@-&gt;exists, &quot;Expected exists error received&quot;);
+    $check-&gt;('i', 5, &quot;ex&quot;);
 }
 
 {
-	diag &quot;Add&quot;;
-	$empty-&gt;('i');
-        $mc-&gt;add('i', 5, 19, &quot;ex&quot;);
-        $check-&gt;('i', 19, &quot;ex&quot;);
-
-	my $rv =()= eval { $mc-&gt;add('i', 5, 19, &quot;ex2&quot;) };
-	is($rv, 0, &quot;Add didn't return anything&quot;);
-	ok($@-&gt;exists, &quot;Expected exists error received&quot;);
-
-	$check-&gt;('i', 19, &quot;ex&quot;);
+    diag &quot;Replace&quot;;
+    $empty-&gt;('j');
+
+    my $rv =()= eval { $mc-&gt;replace('j', &quot;ex&quot;, 19, 5) };
+    is($rv, 0, &quot;Replace didn't return anything&quot;);
+    ok($@-&gt;not_found, &quot;Expected not_found error received&quot;);
+    $empty-&gt;('j');
+    $mc-&gt;add('j', &quot;ex2&quot;, 14, 5);
+    $check-&gt;('j', 14, &quot;ex2&quot;);
+    $mc-&gt;replace('j', &quot;ex3&quot;, 24, 5);
+    $check-&gt;('j', 24, &quot;ex3&quot;);
 }
 
 {
-	diag &quot;Replace&quot;;
-	$empty-&gt;('j');
-
-	my $rv =()= eval { $mc-&gt;replace('j', 5, 19, &quot;ex&quot;) };
-	is($rv, 0, &quot;Replace didn't return anything&quot;);
-	ok($@-&gt;not_found, &quot;Expected not_found error received&quot;);
-
-	$empty-&gt;('j');
-
-	$mc-&gt;add('j', 5, 14, &quot;ex2&quot;);
-	$check-&gt;('j', 14, &quot;ex2&quot;);
-
-	$mc-&gt;replace('j', 5, 24, &quot;ex3&quot;);
-	$check-&gt;('j', 24, &quot;ex3&quot;);
-}
-
-{
-	diag &quot;MultiGet&quot;;
-	$mc-&gt;add('xx', 5, 1, &quot;ex&quot;);
-	$mc-&gt;add('wye', 5, 2, &quot;why&quot;);
-	my $rv = $mc-&gt;getMulti(qw(xx wye zed));
+    diag &quot;MultiGet&quot;;
+    $mc-&gt;add('xx', &quot;ex&quot;, 1, 5);
+    $mc-&gt;add('wye', &quot;why&quot;, 2, 5);
+    my $rv = $mc-&gt;get_multi(qw(xx wye zed));
 
     # CAS is returned with all gets.
     $rv-&gt;{xx}-&gt;[2]  = 0;
     $rv-&gt;{wye}-&gt;[2] = 0;
-	is_deeply($rv-&gt;{xx}, [1, 'ex', 0], &quot;X is correct&quot;);
-	is_deeply($rv-&gt;{wye}, [2, 'why', 0], &quot;Y is correct&quot;);
-	is(keys(%$rv), 2, &quot;Got only two answers like we expect&quot;);
+    is_deeply($rv-&gt;{xx}, [1, 'ex', 0], &quot;X is correct&quot;);
+    is_deeply($rv-&gt;{wye}, [2, 'why', 0], &quot;Y is correct&quot;);
+    is(keys(%$rv), 2, &quot;Got only two answers like we expect&quot;);
 }
 
 diag &quot;Test increment&quot;;
@@ -170,264 +144,247 @@ is($mc-&gt;decr(&quot;x&quot;), 4, &quot;Decrease by one&quot;);
 is($mc-&gt;decr(&quot;x&quot;, 211), 0, &quot;Floor is zero&quot;);
 
 {
-	diag &quot;CAS&quot;;
-	$mc-&gt;flush;
+    diag &quot;CAS&quot;;
+    $mc-&gt;flush;
 
-	{
-		my $rv =()= eval { $mc-&gt;set(&quot;x&quot;, 5, 19, &quot;bad value&quot;, 0x7FFFFFFFFF) };
-		is($rv, 0, &quot;Empty return on expected failure&quot;);
-		ok($@-&gt;not_found, &quot;Error was 'not found' as expected&quot;);
-	}
+    {
+        my $rv =()= eval { $mc-&gt;set(&quot;x&quot;, &quot;bad value&quot;, 19, 5, 0x7FFFFFFFFF) };
+        is($rv, 0, &quot;Empty return on expected failure&quot;);
+        ok($@-&gt;not_found, &quot;Error was 'not found' as expected&quot;);
+    }
 
-	$mc-&gt;add(&quot;x&quot;, 5, 19, &quot;original value&quot;);
+    $mc-&gt;add(&quot;x&quot;, &quot;original value&quot;, 5, 19);
 
-	my ($flags, $val, $i) = $mc-&gt;get(&quot;x&quot;);
-	is($val, &quot;original value&quot;, &quot;-&gt;gets returned proper value&quot;);
+    my ($flags, $val, $i) = $mc-&gt;get(&quot;x&quot;);
+    is($val, &quot;original value&quot;, &quot;-&gt;gets returned proper value&quot;);
 
     {
-		my $rv =()= eval { $mc-&gt;set(&quot;x&quot;, 5, 19, &quot;broken value&quot;, $i+1) };
-		is($rv, 0, &quot;Empty return on expected failure (1)&quot;);
-		ok($@-&gt;exists, &quot;Expected error state of 'exists' (1)&quot;);
-	}
-
-	$mc-&gt;set(&quot;x&quot;, 5, 19, &quot;new value&quot;, $i);
+        my $rv =()= eval { $mc-&gt;set(&quot;x&quot;, &quot;broken value&quot;, 19, 5, $i+1) };
+        is($rv, 0, &quot;Empty return on expected failure (1)&quot;);
+        ok($@-&gt;exists, &quot;Expected error state of 'exists' (1)&quot;);
+    }
 
-	my ($newflags, $newval, $newi) = $mc-&gt;get(&quot;x&quot;);
-	is($newval, &quot;new value&quot;, &quot;CAS properly overwrote value&quot;);
+    $mc-&gt;set(&quot;x&quot;, &quot;new value&quot;, 19, 5, $i);
 
-	{
-		my $rv =()= eval { $mc-&gt;set(&quot;x&quot;, 5, 19, &quot;replay value&quot;, $i) };
-		is($rv, 0, &quot;Empty return on expected failure (2)&quot;);
-		ok($@-&gt;exists, &quot;Expected error state of 'exists' (2)&quot;);
-	}
+    my ($newflags, $newval, $newi) = $mc-&gt;get(&quot;x&quot;);
+    is($newval, &quot;new value&quot;, &quot;CAS properly overwrote value&quot;);
 
-	(undef, my $newval2) = $mc-&gt;get(&quot;x&quot;);
-	is($newval2, &quot;new value&quot;, &quot;CAS replay didn't overwrite value&quot;);
+    {
+        my $rv =()= eval { $mc-&gt;set(&quot;x&quot;, &quot;replay value&quot;, 19, 5,  $i) };
+        is($rv, 0, &quot;Empty return on expected failure (2)&quot;);
+        ok($@-&gt;exists, &quot;Expected error state of 'exists' (2)&quot;);
+    }
 }
 
-$mc-&gt;flush;
-$mc-&gt;close;
-
-
 package MC::Client;
 
 use strict;
 use warnings;
-
 use fields qw(socket);
-
 use IO::Socket::INET;
 
 sub new {
-	my $self = shift;
-
+    my $self = shift;
     my $sock = $server-&gt;sock;
+    $self = fields::new($self);
+    $self-&gt;{socket} = $sock;
+    return $self;
+}
 
-	$self = fields::new($self);
-
-	$self-&gt;{socket} = $sock;
+sub send_command {
+    my $self = shift;
+    die &quot;Not enough args to send_command&quot; unless @_ &gt;= 4;
+    my ($cmd, $key, $val, $opaque, $extra_header, $cas) = @_;
+
+    $extra_header = '' unless defined $extra_header;
+    my $keylen    = length($key);
+    my $vallen    = length($val);
+    my $extralen  = length($extra_header);
+    my $datatype  = 0;  # field for future use
+    my $reserved  = 0;  # field for future use
+    my $totallen  = $keylen + $vallen + $extralen;
+    my $ident_hi  = 0;
+    my $ident_lo  = 0;
+
+    if ($cas) {
+        $ident_hi = int($cas / 2 ** 32);
+        $ident_lo = int($cas % 2 ** 32);
+    }
 
-	return $self;
-}
+    my $msg = pack(::REQ_PKT_FMT, ::REQ_MAGIC, $cmd, $keylen, $extralen, 
+                   $datatype, $reserved, $totallen, $opaque, $ident_hi, 
+                   $ident_lo);
 
-sub close {
-	my $self = shift;
-	return $self-&gt;{socket}-&gt;close(@_);
+	  return $self-&gt;{socket}-&gt;send($msg . $extra_header . $key . $val);
 }
 
-sub _sendCmd {
-	my $self = shift;
-	die &quot;Not enough args to _sendCmd&quot; unless @_ &gt;= 4;
-	my ($cmd, $key, $val, $opaque, $extraHeader) = @_;
+sub _handle_single_response {
+    my $self = shift;
+    my $myopaque = shift;
 
-	$extraHeader = '' unless defined $extraHeader;
+    $self-&gt;{socket}-&gt;recv(my $response, ::MIN_RECV_BYTES);
+    Test::More::is(length($response), ::MIN_RECV_BYTES, &quot;Expected read length&quot;);
 
-	my $keylen = length($key);
-	my $vallen = length($val);
-	my $extralen = length($extraHeader);
+    my ($magic, $cmd, $keylen, $extralen, $datatype, $status, $remaining, 
+        $opaque, $ident_hi, $ident_lo) = unpack(::RES_PKT_FMT, $response);
+    Test::More::is($magic, ::RES_MAGIC, &quot;Got proper response magic&quot;);
 
-	my $msg = pack(::PKT_FMT, ::REQ_MAGIC_BYTE, $cmd, $keylen, $extralen,
-                    $keylen + $vallen + $extralen, $opaque);
-	return $self-&gt;{socket}-&gt;send($msg . $extraHeader . $key . $val);
-}
+    return ($opaque, '') if($remaining == 0);
 
-sub _handleSingleResponse {
-	my $self = shift;
-	my $myopaque = shift;
+    # fetch the value
+    $self-&gt;{socket}-&gt;recv(my $rv, $remaining);
 
-	$self-&gt;{socket}-&gt;recv(my $response, ::MIN_RECV_PACKET);
+    if (defined $myopaque) {
+        Test::More::is($opaque, $myopaque, &quot;Expected opaque&quot;);
+    } else {
+        Test::More::pass(&quot;Implicit pass since myopaque is undefined&quot;);
+    }
 
-	Test::More::is(length($response), ::MIN_RECV_PACKET, &quot;Expected read length&quot;);
+    my $cas = ($ident_hi * 2 ** 32) + $ident_lo;
 
-	my ($magic, $cmd, $errcode, $extralen, $remaining,
-        $opaque) = unpack(::PKT_FMT, $response);
+    if ($status) {
+        die MC::Error-&gt;new($status, $rv);
+    }
 
-	Test::More::is($magic, ::RES_MAGIC_BYTE, &quot;Got proper magic&quot;);
+    return ($opaque, $rv, $cas);
+}
 
-	return ($opaque, &quot;&quot;)
-		if $remaining == 0;
+sub _do_command {
+    my $self = shift;
+    die unless @_ &gt;= 3;
+    my ($cmd, $key, $val, $extra_header, $cas) = @_;
 
-	$self-&gt;{socket}-&gt;recv(my $rv, $remaining);
+    $extra_header = '' unless defined $extra_header;
+    my $opaque = int(rand(2**32));
+    $self-&gt;send_command($cmd, $key, $val, $opaque, $extra_header, $cas);
+    (undef, my $rv, my $rcas) = $self-&gt;_handle_single_response($opaque);
+    return ($rv, $rcas);
+}
 
-	if (defined $myopaque) {
-		Test::More::is($opaque, $myopaque, &quot;Expected opaque&quot;);
-	} else {
-		Test::More::pass(&quot;Implicit pass since myopaque is undefined&quot;);
-	}
+sub _incrdecr {
+    my $self = shift;
+    my ($cmd, $key, $amt, $init, $exp) = @_;
 
-	if ($errcode) {
-		die MC::Error-&gt;new($errcode, $rv);
-	}
+    my $amt_hi = int($amt / 2 ** 32);
+    my $amt_lo = int($amt % 2 ** 32);
 
-	return ($opaque, $rv);
-}
+    my $init_hi = int($init / 2 ** 32);
+    my $init_lo = int($init % 2 ** 32);
 
-sub _doCmd {
-	my $self = shift;
-	die unless @_ &gt;= 3;
-	my ($cmd, $key, $val, $extraHeader) = @_;
+    my $extra_header = pack(::INCRDECR_PKT_FMT, $amt_hi, $amt_lo, $init_hi, 
+                            $init_lo, $exp);
 
-	$extraHeader = '' unless defined $extraHeader;
+    my ($data, undef) = $self-&gt;_do_command($cmd, $key, '', $extra_header);
 
-	my $opaque = int(rand(2**32));
+    my $header = substr $data, 0, 8, '';
+    my ($resp_hi, $resp_lo) = unpack &quot;NN&quot;, $header;
+    my $resp = ($resp_hi * 2 ** 32) + $resp_lo;
 
-	$self-&gt;_sendCmd($cmd, $key, $val, $opaque, $extraHeader);
-	(undef, my $rv) = $self-&gt;_handleSingleResponse($opaque);
-	return $rv;
+    return $resp;
 }
 
-sub __parseGet {
-	my $self = shift;
-	my $rv = shift; # currently contains 4 bytes of 'flag' followed by value
-	my $header = substr $rv, 0, 12, '';
-	my ($ident_hi, $ident_lo, $flags) = unpack &quot;NNN&quot;, $header;
-	my $ident = ($ident_hi * 2 ** 32) + $ident_lo;
+sub get {
+    my $self = shift;
+    my $key  = shift;
+    my ($rv, $cas) = $self-&gt;_do_command(::CMD_GET, $key, '', ''); 
 
-	return $flags, $rv, $ident;
-}
+    my $header = substr $rv, 0, 4, '';
+    my $flags  = unpack(&quot;N&quot;, $header);
 
-sub get {
-	my $self = shift;
-	my $key = shift;
-	my $parts = $self-&gt;_doCmd(::CMD_GET, $key, '');
-	return $self-&gt;__parseGet($parts);
+    return ($flags, $rv, $cas);
 }
 
-sub _mutate {
-	my $self = shift;
-	my ($cmd, $key, $exp, $flags, $val, $ident) = @_;
+sub get_multi {
+    my $self = shift;
+    my @keys = @_;
 
-    my $ident_hi = 0;
-    my $ident_lo = 0;
-    if ($ident) {
-        $ident_hi = int($ident / 2 ** 32);
-        $ident_lo = int($ident % 2 ** 32);
+    for (my $i = 0; $i &lt; @keys; $i++) {
+        $self-&gt;send_command(::CMD_GETQ, $keys[$i], '', $i, '', 0);
     }
 
-	return $self-&gt;_doCmd($cmd, $key, $val, pack(::SET_PKT_FMT, $ident_hi, $ident_lo, $flags, $exp));
-}
-
-sub set {
-	my $self = shift;
-	my ($key, $exp, $flags, $val, $ident) = @_;
-
-	return $self-&gt;_mutate(::CMD_SET, $key, $exp, $flags, $val, $ident);
-}
+    my $terminal = @keys + 10;
+	  $self-&gt;send_command(::CMD_NOOP, '', '', $terminal);
 
-sub __incrdecr {
-	my $self = shift;
-	my ($cmd, $key, $amt, $init, $exp) = @_;
+    my %return;
+    while (1) {
+        my ($opaque, $data) = $self-&gt;_handle_single_response;
+        last if $opaque == $terminal;
 
-	my $amt_hi = int($amt / 2 ** 32);
-	my $amt_lo = int($amt % 2 ** 32);
+        my $header = substr $data, 0, 4, '';
+        my $flags  = unpack(&quot;N&quot;, $header);
 
-	my $init_hi = int($init / 2 ** 32);
-	my $init_lo = int($init % 2 ** 32);
+        $return{$keys[$opaque]} = [$flags, $data];
+    }
 
-	my $data = $self-&gt;_doCmd($cmd, $key, '', pack(::INCRDECR_PKT_FMT, $amt_hi, $amt_lo, $init_hi, $init_lo, $exp));
-	my $header = substr $data, 0, 12, '';
-	my ($resp_hi, $resp_lo) = unpack &quot;NN&quot;, $header;
-	my $resp = ($resp_hi * 2 ** 32) + $resp_lo;
-    return $resp;
+    return %return if wantarray;
+    return \%return;
 }
 
-sub incr {
-	my $self = shift;
-	my ($key, $amt, $init, $exp) = @_;
-	$amt = 1 unless defined $amt;
-	$init = 0 unless defined $init;
-	$exp = 0 unless defined $exp;
-
-	return $self-&gt;__incrdecr(::CMD_INCR, $key, $amt, $init, $exp);
+sub version {
+    my $self = shift;
+    return $self-&gt;_do_command(::CMD_VERSION, '', '');
 }
 
-sub decr {
-	my $self = shift;
-	my ($key, $amt, $init, $exp) = @_;
-	$amt = 1 unless defined $amt;
-	$init = 0 unless defined $init;
-	$exp = 0 unless defined $exp;
-
-	return $self-&gt;__incrdecr(::CMD_DECR, $key, $amt, $init, $exp);
+sub flush {
+    my $self = shift;
+    return $self-&gt;_do_command(::CMD_FLUSH, '', '');
 }
 
 sub add {
-	my $self = shift;
-	my ($key, $exp, $flags, $val) = @_;
-	return $self-&gt;_mutate(::CMD_ADD, $key, $exp, $flags, $val);
-}
-sub replace {
-	my $self = shift;
-	my ($key, $exp, $flags, $val) = @_;
-	return $self-&gt;_mutate(::CMD_REPLACE, $key, $exp, $flags, $val);
+    my $self = shift;
+    my ($key, $val, $flags, $expire) = @_;
+    my $extra_header = pack &quot;NN&quot;, $flags, $expire;
+    my $cas = 0;
+    return $self-&gt;_do_command(::CMD_ADD, $key, $val, $extra_header, $cas);
 }
 
-sub getMulti {
-	my $self = shift;
-	my @keys = @_;
-
-	for (my $i = 0; $i &lt; @keys; $i++) {
-		$self-&gt;_sendCmd(::CMD_GETQ, $keys[$i], '', $i);
-	}
-
-	my $terminal = @keys + 10;
-	$self-&gt;_sendCmd(::CMD_NOOP, '', '', $terminal);
-
-	my %return;
-
-	while (1) {
-		my ($opaque, $data) = $self-&gt;_handleSingleResponse;
-		last if $opaque == $terminal;
-
-		$return{$keys[$opaque]} = [$self-&gt;__parseGet($data)];
-	}
-	return %return if wantarray;
-	return \%return;
+sub set {
+    my $self = shift;
+    my ($key, $val, $flags, $expire, $cas) = @_;
+    my $extra_header = pack &quot;NN&quot;, $flags, $expire;
+    return $self-&gt;_do_command(::CMD_SET, $key, $val, $extra_header, $cas);
 }
 
-sub noop {
-	my $self = shift;
-	return $self-&gt;_doCmd(::CMD_NOOP, '', '');
+sub replace {
+    my $self = shift;
+    my ($key, $val, $flags, $expire) = @_;
+    my $extra_header = pack &quot;NN&quot;, $flags, $expire;
+    my $cas = 0;
+    return $self-&gt;_do_command(::CMD_REPLACE, $key, $val, $extra_header, $cas);
 }
 
 sub delete {
-	my $self = shift;
-	my ($key, $when) = @_;
-	$when = 0 unless defined $when;
+    my $self = shift;
+    my ($key) = @_;
+    return $self-&gt;_do_command(::CMD_DELETE, $key, '');
+}
 
-	return $self-&gt;_doCmd(::CMD_DELETE, $key, '', pack(::DEL_PKT_FMT, $when));
+sub incr {
+    my $self = shift;
+    my ($key, $amt, $init, $exp) = @_;
+    $amt = 1 unless defined $amt;
+    $init = 0 unless defined $init;
+    $exp = 0 unless defined $exp;
+
+    return $self-&gt;_incrdecr(::CMD_INCR, $key, $amt, $init, $exp);
 }
 
-sub version {
-	my $self = shift;
-	return $self-&gt;_doCmd(::CMD_VERSION, '', '');
+sub decr {
+    my $self = shift;
+    my ($key, $amt, $init, $exp) = @_;
+    $amt = 1 unless defined $amt;
+    $init = 0 unless defined $init;
+    $exp = 0 unless defined $exp;
+
+    return $self-&gt;_incrdecr(::CMD_DECR, $key, $amt, $init, $exp);
 }
 
-sub flush {
-	my $self = shift;
-	return $self-&gt;_doCmd(::CMD_FLUSH, '', '');
+sub noop {
+    my $self = shift;
+    return $self-&gt;_do_command(::CMD_NOOP, '', '');
 }
 
+
 package MC::Error;
 
 use strict;
@@ -438,31 +395,27 @@ use constant ERR_NOT_FOUND   =&gt; 0x1;
 use constant ERR_EXISTS      =&gt; 0x2;
 
 use overload '&quot;&quot;' =&gt; sub {
-	my $self = shift;
-
-	return &quot;Memcache Error ($self-&gt;[0]): $self-&gt;[1]&quot;;
+    my $self = shift;
+    return &quot;Memcache Error ($self-&gt;[0]): $self-&gt;[1]&quot;;
 };
 
 sub new {
-	my $class = shift;
-	my $error = [@_];
-
-	my $self = bless $error, (ref $class || $class);
+    my $class = shift;
+    my $error = [@_];
+    my $self = bless $error, (ref $class || $class);
 
-	return $self;
+    return $self;
 }
 
 sub not_found {
-	my $self = shift;
-
-	return $self-&gt;[0] == ERR_NOT_FOUND;
+    my $self = shift;
+    return $self-&gt;[0] == ERR_NOT_FOUND;
 }
 
 sub exists {
-	my $self = shift;
-
-	return $self-&gt;[0] == ERR_EXISTS;
+    my $self = shift;
+    return $self-&gt;[0] == ERR_EXISTS;
 }
 
 # vim: filetype=perl
-=cut
+</diff>
      <filename>t/binary.t</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>cb8145061d7abe40bfafd4abd4661d31522ed670</id>
    </parent>
  </parents>
  <author>
    <name>Toru Maesaka</name>
    <email>dev@torum.net</email>
  </author>
  <url>http://github.com/tmaesaka/memcached/commit/67b4da9eb855ebe7695a197320232b8d25692f84</url>
  <id>67b4da9eb855ebe7695a197320232b8d25692f84</id>
  <committed-date>2008-08-14T23:57:09-07:00</committed-date>
  <authored-date>2008-08-14T23:57:09-07:00</authored-date>
  <message>Binary protocol test now complies with the latest specification.</message>
  <tree>f17d7afb763013877ae170d5bf29920e9361682d</tree>
  <committer>
    <name>Toru Maesaka</name>
    <email>dev@torum.net</email>
  </committer>
</commit>
