changeset 2:f5cfb726ea65 default tip

Append/prepend commands. NOTE: gzipping content may produce unpredictable results.
author Maxim Dounin <mdounin@mdounin.ru>
date Sun, 30 Sep 2007 18:01:41 +0400
parents d0f7d74f9ca5
children
files lib/Cache/Memcached.pm t/02_keys.t
diffstat 2 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lib/Cache/Memcached.pm	Sun Sep 30 16:23:48 2007 +0400
+++ b/lib/Cache/Memcached.pm	Sun Sep 30 18:01:41 2007 +0400
@@ -437,6 +437,14 @@
     _set("set", @_);
 }
 
+sub append {
+    _set("append", @_);
+}
+
+sub prepend {
+    _set("prepend", @_);
+}
+
 sub _set {
     my $cmdname = shift;
     my Cache::Memcached $self = shift;
--- a/t/02_keys.t	Sun Sep 30 16:23:48 2007 +0400
+++ b/t/02_keys.t	Sun Sep 30 18:01:41 2007 +0400
@@ -9,7 +9,7 @@
 my $msock = IO::Socket::INET->new(PeerAddr => $testaddr,
                                   Timeout  => 3);
 if ($msock) {
-    plan tests => 10;
+    plan tests => 14;
 } else {
     plan skip_all => "No memcached instance running at $testaddr\n";
     exit 0;
@@ -31,6 +31,11 @@
 ok($memd->replace("key2", "val-replace"), "replace worked");
 ok(! $memd->replace("key-noexist", "bogus"), "replace failed");
 
+ok($memd->set("key1", "1"), "set before append/prepend");
+ok($memd->append("key1", "2"), "append worked");
+ok($memd->prepend("key1", "3"), "prepend worked");
+is($memd->get("key1"), "312", "append/prepend result check");
+
 my $stats = $memd->stats;
 ok($stats, "got stats");
 is(ref $stats, "HASH", "is a hashref");