r35540 - in /trunk/libcache-memcached-perl: ./ debian/ lib/Cache/ t/

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Sun May 17 03:25:11 UTC 2009


Author: jawnsy-guest
Date: Sun May 17 03:25:04 2009
New Revision: 35540

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=35540
Log:
Updated to new upstream version. Various changes (see debian/changelog for details). dch -r.

Added:
    trunk/libcache-memcached-perl/t/04_noreply.t
    trunk/libcache-memcached-perl/t/05_reconnect_timeout.t
    trunk/libcache-memcached-perl/t/100_flush_bug.t
Removed:
    trunk/libcache-memcached-perl/debian/docs
    trunk/libcache-memcached-perl/debian/libcache-memcached-perl.docs
Modified:
    trunk/libcache-memcached-perl/ChangeLog
    trunk/libcache-memcached-perl/MANIFEST
    trunk/libcache-memcached-perl/META.yml
    trunk/libcache-memcached-perl/debian/changelog
    trunk/libcache-memcached-perl/debian/compat
    trunk/libcache-memcached-perl/debian/control
    trunk/libcache-memcached-perl/debian/copyright
    trunk/libcache-memcached-perl/debian/rules
    trunk/libcache-memcached-perl/lib/Cache/Memcached.pm
    trunk/libcache-memcached-perl/t/01_use.t
    trunk/libcache-memcached-perl/t/02_keys.t
    trunk/libcache-memcached-perl/t/03_stats.t

Modified: trunk/libcache-memcached-perl/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcache-memcached-perl/ChangeLog?rev=35540&op=diff
==============================================================================
--- trunk/libcache-memcached-perl/ChangeLog (original)
+++ trunk/libcache-memcached-perl/ChangeLog Sun May 17 03:25:04 2009
@@ -1,3 +1,27 @@
+2009-05-04: version 1.26
+
+	* don't include "stats sizes" by default in the stats method,
+	  as that can hang big servers for a few seconds (Brad Fitzpatrick)
+	
+2009-05-02: version 1.25
+
+	* Clear @buck2sock when calling disconnect_all.  (Dennis Stosberg,
+	  [rt.cpan.org #45560]
+	
+	* Reconnects to a dead connection shouldn't happen every time when the
+	  connection has never succeded. Apply the dead timeout to sockets that
+	  never even came up. Add a test.
+
+	* Warn when trying to put undef values into memcache.
+	  (Henry Lyne <hlyne at livejournalinc.com>)
+	
+	* flush_all now only returns success if there is a proper reply from all
+	  servers - Yann Kerherve <yann at sixapart.com>
+	
+	* 'noreply' support from Tomash Brechko <tomash.brechko at gmail.com>
+
+	* various test updates from Ronald J Kimball <rkimball at pangeamedia.com>
+
 2007-07-17: version 1.24
 
 	* update the stats method, including tests for it

Modified: trunk/libcache-memcached-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcache-memcached-perl/MANIFEST?rev=35540&op=diff
==============================================================================
--- trunk/libcache-memcached-perl/MANIFEST (original)
+++ trunk/libcache-memcached-perl/MANIFEST Sun May 17 03:25:04 2009
@@ -1,12 +1,15 @@
 ChangeLog
+MANIFEST
+MANIFEST.SKIP
+Makefile.PL
+README
+TODO
 lib/Cache/Memcached.pm
 lib/Cache/Memcached/GetParser.pm
-Makefile.PL
-README
-MANIFEST
-MANIFEST.SKIP
-TODO
 t/01_use.t
 t/02_keys.t
 t/03_stats.t
+t/04_noreply.t
+t/05_reconnect_timeout.t
+t/100_flush_bug.t
 META.yml                                 Module meta-data (added by MakeMaker)

Modified: trunk/libcache-memcached-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcache-memcached-perl/META.yml?rev=35540&op=diff
==============================================================================
--- trunk/libcache-memcached-perl/META.yml (original)
+++ trunk/libcache-memcached-perl/META.yml Sun May 17 03:25:04 2009
@@ -1,13 +1,16 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
-name:         Cache-Memcached
-version:      1.24
-version_from: lib/Cache/Memcached.pm
-installdirs:  site
-requires:
+--- #YAML:1.0
+name:                Cache-Memcached
+version:             1.26
+abstract:            client library for memcached (memory cache daemon)
+license:             ~
+author:              
+    - Brad Fitzpatrick <brad at danga.com>
+generated_by:        ExtUtils::MakeMaker version 6.42
+distribution_type:   module
+requires:     
     Storable:                      0
     String::CRC32:                 0
     Time::HiRes:                   0
-
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
+meta-spec:
+    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
+    version: 1.3

Modified: trunk/libcache-memcached-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcache-memcached-perl/debian/changelog?rev=35540&op=diff
==============================================================================
--- trunk/libcache-memcached-perl/debian/changelog (original)
+++ trunk/libcache-memcached-perl/debian/changelog Sun May 17 03:25:04 2009
@@ -1,10 +1,23 @@
-libcache-memcached-perl (1.24-2) UNRELEASED; urgency=low
+libcache-memcached-perl (1.26-1) unstable; urgency=low
 
+  [ Jonathan Yu ]
+  * New upstream release
+  * Statistics for 'sizes' is gone in this version, because it could cause
+    servers to freeze for several seconds
+  * More warnings are now set up; this is mainly a bugfix release to close
+    bugs on the upstream Request Tracker
+  * Upgraded to debhelper 7 from debhelper 5
+  * Updated long description
+  * Added /me to uploaders
+  * Removed docs links (they point to README/TODO; README is next to useless
+    and the TODO file is empty)
+
+  [ gregor herrmann ]
   * debian/control: Changed: Switched Vcs-Browser field to ViewSVN
     (source stanza).
   * debian/control: Added: ${misc:Depends} to Depends: field.
 
- -- gregor herrmann <gregoa at debian.org>  Sun, 16 Nov 2008 20:40:09 +0100
+ -- Jonathan Yu <frequency at cpan.org>  Sat, 16 May 2009 22:54:40 -0400
 
 libcache-memcached-perl (1.24-1) unstable; urgency=low
 

Modified: trunk/libcache-memcached-perl/debian/compat
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcache-memcached-perl/debian/compat?rev=35540&op=diff
==============================================================================
--- trunk/libcache-memcached-perl/debian/compat (original)
+++ trunk/libcache-memcached-perl/debian/compat Sun May 17 03:25:04 2009
@@ -1,1 +1,1 @@
-5
+7

Modified: trunk/libcache-memcached-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcache-memcached-perl/debian/control?rev=35540&op=diff
==============================================================================
--- trunk/libcache-memcached-perl/debian/control (original)
+++ trunk/libcache-memcached-perl/debian/control Sun May 17 03:25:04 2009
@@ -3,9 +3,10 @@
 Priority: optional
 Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
 Uploaders: Jay Bonci <jaybonci at debian.org>
-Build-Depends: debhelper (>= 5)
-Build-Depends-Indep: perl (>= 5.6.0-16), libstring-crc32-perl
-Standards-Version: 3.7.3
+Uploaders: Jonathan Yu <frequency at cpan.org>
+Build-Depends: debhelper (>= 7)
+Build-Depends-Indep: libstring-crc32-perl, perl (>= 5.6.0-16)
+Standards-Version: 3.8.1
 Homepage: http://search.cpan.org/dist/Cache-Memcached/
 Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libcache-memcached-perl/
 Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libcache-memcached-perl/
@@ -14,8 +15,13 @@
 Architecture: all
 Depends: ${misc:Depends}, ${perl:Depends}, libstring-crc32-perl
 Suggests: memcached
-Description: Cache::Memcached - client library for memcached
- This is the Perl API for memcached, a distributed memory cache daemon. It 
- is an object-oriented and feature rich client API implementation, and is
- used as a component to power several large websites, including Livejournal
- and Slashdot.
+Description: Perl module for using memcached servers
+ Cache::Memcached is a module that interfaces with the memcached distributed
+ memory cache daemon. Danga Interactive's memcached is a generic memory object
+ caching system, often used to accelerate dynamic web sites by reducing load
+ on slower databases. (See the memcached package for details)
+ .
+ This module allows Perl authors to quickly set and retrieve key/data pairs
+ from memcached servers, even clusters of multiple daemons. As such, it is
+ used to power several large-scale and high-performance web sites, including
+ LiveJournal and Slashdot.

Modified: trunk/libcache-memcached-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcache-memcached-perl/debian/copyright?rev=35540&op=diff
==============================================================================
--- trunk/libcache-memcached-perl/debian/copyright (original)
+++ trunk/libcache-memcached-perl/debian/copyright Sun May 17 03:25:04 2009
@@ -1,33 +1,32 @@
-This package was debianized by Jay Bonci <jaybonci at debian.org> on
-Tue, 28 Oct 2003 15:34:37 -0500.
+Format-Specification:
+    http://wiki.debian.org/Proposals/CopyrightFormat?action=recall&rev=196
+Upstream-Maintainer: Brad Fitzpatrick <brad at danga.com>
+Upstream-Source: http://search.cpan.org/dist/Cache-Memcached/
+Upstream-Name: Cache-Memcached
 
-It was downloaded from: http://search.cpan.org/dist/Cache-Memcached
-
-Upstream Authors:
-	Brad Fitzpatrick <brad at danga.com>
-	Anatoly Vorobey <mellon at pobox.com>
-	Brad Whitaker <whitaker at danga.com>
-	Jamie McCarthy <jamie at mccarthy.vg>
+Files: *
+Copyright: 2003-2007, Brad Fitzpatrick <brad at danga.com>
+License-Alias: Perl
+License: Artistic | GPL-1+
 
 Files: debian/*
-Copyright: © 2007 Martín Ferrari
-	   © 2007 Jeremiah C. Foster
-	   © 2007 gregor herrmann
-           © 2003-2007 Jay Bonci
-License: other
- It is being assumed that all maintainers did choose a license compatible with
- the license used by upstream
+Copyright: 2009, Jonathan Yu <frequency at cpan.org>
+ 2007, Martín Ferrari <martin.ferrari at gmail.com>
+ 2007, Gunnar Wolf <gwolf at debian.org>
+ 2007, gregor herrmann <gregor+debian at comodo.priv.at>
+ 2003-2007, Jay Bonci <jaybonci at debian.org>
+License: Artistic | GPL-1+
 
-Files: *
-Copyright: © 2003-2007 Brad Fitzpatrick. All rights reserved.
-License: Artistic | GPL-1+
- This module is Copyright (c) 2003 Brad Fitzpatrick.
- All rights reserved.
- .
- You may distribute under the terms of either the GNU General Public
- License or the Artistic License, as specified in the Perl README file.
+License: GPL-1+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 1, or (at your option)
+    any later version.
+    On Debian GNU/Linux systems, the complete text of the GNU General
+    Public License can be found in `/usr/share/common-licenses/GPL'
 
-On Debian GNU/Linux systems, the complete text of the GNU General Public
-License can be found in `/usr/share/common-licenses/GPL' and the Artistic
-License in `/usr/share/common-licenses/Artistic'.
-
+License: Artistic
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the Artistic License, which comes with Perl.
+    On Debian GNU/Linux systems, the complete text of the Artistic License
+    can be found in `/usr/share/common-licenses/Artistic'

Modified: trunk/libcache-memcached-perl/debian/rules
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcache-memcached-perl/debian/rules?rev=35540&op=diff
==============================================================================
--- trunk/libcache-memcached-perl/debian/rules (original)
+++ trunk/libcache-memcached-perl/debian/rules Sun May 17 03:25:04 2009
@@ -1,56 +1,23 @@
 #!/usr/bin/make -f
-# Sample debian/rules that uses debhelper.
-# GNU copyright 1997 to 1999 by Joey Hess.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-PACKAGE = $(shell dh_listpackages)
-TMP = $(CURDIR)/debian/$(PACKAGE)
-
-ifndef PERL
-PERL = /usr/bin/perl
-endif
 
 build: build-stamp
 build-stamp:
-	dh_testdir
-	$(PERL) Makefile.PL INSTALLDIRS=vendor \
-		INSTALLVENDORARCH=/usr/share/perl5/ \
-		VENDORARCHEXP=/usr/share/perl5/
-	$(MAKE)
-	$(MAKE) test
-	
+	dh build
 	touch $@
 
 clean:
-	dh_testdir
-	dh_testroot
-	dh_clean build-stamp install-stamp
-	[ ! -f Makefile ] || $(MAKE) realclean
+	dh $@
 
 install: install-stamp
 install-stamp: build-stamp
-	dh_testdir
-	dh_testroot
-	dh_clean -k
-	dh_installdirs
-	$(MAKE) install DESTDIR=$(TMP) PREFIX=/usr
+	dh install
 	touch $@
 
 binary-arch:
-binary-indep: build install
-	dh_testdir
-	dh_testroot
-	dh_installdocs -XTODO
-	dh_installchangelogs ChangeLog
-	dh_perl
-	dh_compress
-	dh_fixperms
-	dh_installdeb
-	dh_gencontrol
-	dh_md5sums
-	dh_builddeb
 
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary
+binary-indep: install
+	dh $@
+
+binary: binary-arch binary-indep
+
+.PHONY: binary binary-arch binary-indep install clean build

Modified: trunk/libcache-memcached-perl/lib/Cache/Memcached.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcache-memcached-perl/lib/Cache/Memcached.pm?rev=35540&op=diff
==============================================================================
--- trunk/libcache-memcached-perl/lib/Cache/Memcached.pm (original)
+++ trunk/libcache-memcached-perl/lib/Cache/Memcached.pm Sun May 17 03:25:04 2009
@@ -1,4 +1,4 @@
-# $Id: Memcached.pm 601 2007-07-17 17:47:33Z bradfitz $
+# $Id: Memcached.pm 811 2009-05-05 01:32:37Z bradfitz $
 #
 # Copyright (c) 2003, 2004  Brad Fitzpatrick <brad at danga.com>
 #
@@ -35,7 +35,7 @@
 use constant COMPRESS_SAVINGS => 0.20; # percent
 
 use vars qw($VERSION $HAVE_ZLIB $FLAG_NOSIGNAL);
-$VERSION = "1.24";
+$VERSION = "1.26";
 
 BEGIN {
     $HAVE_ZLIB = eval "use Compress::Zlib (); 1;";
@@ -244,6 +244,7 @@
         # if a preferred IP is known, try that first.
         if ($self && $self->{pref_ip}{$ip}) {
             socket($sock, PF_INET, SOCK_STREAM, $proto);
+            $sock_map{$sock} = $host;
             my $prefip = $self->{pref_ip}{$ip};
             $sin = Socket::sockaddr_in($port,Socket::inet_aton($prefip));
             if (_connect_sock($sock,$sin,$self->{connect_timeout})) {
@@ -259,6 +260,7 @@
         # normal path, or fallback path if preferred IP failed
         unless ($connected) {
             socket($sock, PF_INET, SOCK_STREAM, $proto);
+            $sock_map{$sock} = $host;
             $sin = Socket::sockaddr_in($port,Socket::inet_aton($ip));
             my $timeout = $self ? $self->{connect_timeout} : 0.25;
             unless (_connect_sock($sock,$sin,$timeout)) {
@@ -269,6 +271,7 @@
         }
     } else { # it's a unix domain/local socket
         socket($sock, PF_UNIX, SOCK_STREAM, 0);
+        $sock_map{$sock} = $host;
         $sin = Socket::sockaddr_un($host);
         my $timeout = $self ? $self->{connect_timeout} : 0.25;
         unless (_connect_sock($sock,$sin,$timeout)) {
@@ -283,7 +286,6 @@
     $| = 1;
     select($old);
 
-    $sock_map{$sock} = $host;
     $cache_sock{$host} = $sock;
 
     return $sock;
@@ -328,6 +330,7 @@
         close $sock;
     }
     %cache_sock = ();
+    @buck2sock = ();
 }
 
 # writes a line, then reads result.  by default stops reading after a
@@ -421,7 +424,7 @@
         $self->{'stat_callback'}->($stime, $etime, $sock, 'delete');
     }
 
-    return $res eq "DELETED\r\n";
+    return defined $res && $res eq "DELETED\r\n";
 }
 *remove = \&delete;
 
@@ -457,6 +460,7 @@
         $val = Storable::nfreeze($val);
         $flags |= F_STORABLE;
     }
+    warn "value for memkey:$key is not defined" unless defined $val;
 
     my $len = length($val);
 
@@ -491,7 +495,7 @@
         $self->{'stat_callback'}->($stime, $etime, $sock, $cmdname);
     }
 
-    return $res eq "STORED\r\n";
+    return defined $res && $res eq "STORED\r\n";
 }
 
 sub incr {
@@ -522,7 +526,7 @@
         $self->{'stat_callback'}->($stime, $etime, $sock, $cmdname);
     }
 
-    return undef unless $res =~ /^(\d+)/;
+    return undef unless defined $res && $res =~ /^(\d+)/;
     return $1;
 }
 
@@ -783,7 +787,7 @@
     foreach my $host (@hosts) {
         my $sock = $self->sock_to_host($host);
         my @res = $self->run_command($sock, "flush_all\r\n");
-        $success = 0 unless (@res);
+        $success = 0 unless (scalar @res == 1 && (($res[0] || "") eq "OK\r\n"));
     }
 
     return $success;
@@ -815,8 +819,10 @@
             # I don't much care what the default is, it should just
             # be something reasonable.  Obviously "reset" should not
             # be on the list :) but other types that might go in here
-            # include maps, cachedump, slabs, or items.
-            $types = [ qw( misc malloc sizes self ) ];
+            # include maps, cachedump, slabs, or items.  Note that
+            # this does NOT include 'sizes' anymore, as that can freeze
+            # bug servers for a couple seconds.
+            $types = [ qw( misc malloc self ) ];
         } else {
             $types = [ $types ];
         }
@@ -894,7 +900,7 @@
   HOST: foreach my $host (@{$self->{'buckets'}}) {
         my $sock = $self->sock_to_host($host);
         my $ok = _write_and_read($self, $sock, "stats reset");
-        unless ($ok eq "RESET\r\n") {
+        unless (defined $ok && $ok eq "RESET\r\n") {
             _dead_sock($sock);
         }
     }

Modified: trunk/libcache-memcached-perl/t/01_use.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcache-memcached-perl/t/01_use.t?rev=35540&op=diff
==============================================================================
--- trunk/libcache-memcached-perl/t/01_use.t (original)
+++ trunk/libcache-memcached-perl/t/01_use.t Sun May 17 03:25:04 2009
@@ -1,7 +1,8 @@
 #!/usr/bin/env perl -w
+
 use strict;
-use Test;
-BEGIN { plan tests => 1 }
+use Test::More;
 
-use Cache::Memcached; ok(1);
-exit;
+plan tests => 1;
+
+use_ok('Cache::Memcached');

Modified: trunk/libcache-memcached-perl/t/02_keys.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcache-memcached-perl/t/02_keys.t?rev=35540&op=diff
==============================================================================
--- trunk/libcache-memcached-perl/t/02_keys.t (original)
+++ trunk/libcache-memcached-perl/t/02_keys.t Sun May 17 03:25:04 2009
@@ -1,4 +1,4 @@
-# -*-perl-*-
+#!/usr/bin/env perl -w
 
 use strict;
 use Test::More;
@@ -9,7 +9,7 @@
 my $msock = IO::Socket::INET->new(PeerAddr => $testaddr,
                                   Timeout  => 3);
 if ($msock) {
-    plan tests => 10;
+    plan tests => 13;
 } else {
     plan skip_all => "No memcached instance running at $testaddr\n";
     exit 0;
@@ -20,25 +20,27 @@
     namespace => "Cache::Memcached::t/$$/" . (time() % 100) . "/",
 });
 
+isa_ok($memd, 'Cache::Memcached');
 
-ok($memd->set("key1", "val1"), "set succeeded");
+ok($memd->set("key1", "val1"), "set key1 as val1");
 
-is($memd->get("key1"), "val1", "get worked");
-ok(! $memd->add("key1", "val-replace"), "add properly failed");
-ok($memd->add("key2", "val2"), "add worked on key2");
-is($memd->get("key2"), "val2", "get worked");
+is($memd->get("key1"), "val1", "get key1 is val1");
+ok(! $memd->add("key1", "val-replace"), "add key1 properly failed");
+ok($memd->add("key2", "val2"), "add key2 as val2");
+is($memd->get("key2"), "val2", "get key2 is val2");
 
-ok($memd->replace("key2", "val-replace"), "replace worked");
-ok(! $memd->replace("key-noexist", "bogus"), "replace failed");
+ok($memd->replace("key2", "val-replace"), "replace key2 as val-replace");
+is($memd->get("key2"), "val-replace", "get key2 is val-replace");
+ok(! $memd->replace("key-noexist", "bogus"), "replace key-noexist properly failed");
 
-my $stats = $memd->stats;
-ok($stats, "got stats");
-is(ref $stats, "HASH", "is a hashref");
+ok($memd->delete("key1"), "delete key1");
+ok(! $memd->get("key1"), "get key1 properly failed");
 
 
-# also make one without a hashref
+# also test creating the object with a list rather than a hash-ref
 my $mem2 = Cache::Memcached->new(
                                  servers   => [ ],
                                  debug     => 1,
-                                 );
+                                );
+isa_ok($mem2, 'Cache::Memcached');
 ok($mem2->{debug}, "debug is set on alt constructed instance");

Modified: trunk/libcache-memcached-perl/t/03_stats.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcache-memcached-perl/t/03_stats.t?rev=35540&op=diff
==============================================================================
--- trunk/libcache-memcached-perl/t/03_stats.t (original)
+++ trunk/libcache-memcached-perl/t/03_stats.t Sun May 17 03:25:04 2009
@@ -1,4 +1,4 @@
-# -*-perl-*-
+#!/usr/bin/env perl -w
 
 use strict;
 use Test::More;

Added: trunk/libcache-memcached-perl/t/04_noreply.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcache-memcached-perl/t/04_noreply.t?rev=35540&op=file
==============================================================================
--- trunk/libcache-memcached-perl/t/04_noreply.t (added)
+++ trunk/libcache-memcached-perl/t/04_noreply.t Sun May 17 03:25:04 2009
@@ -1,0 +1,52 @@
+#!/usr/bin/env perl -w
+
+use strict;
+use Test::More;
+use Cache::Memcached;
+use IO::Socket::INET;
+
+my $testaddr = "127.0.0.1:11211";
+my $msock = IO::Socket::INET->new(PeerAddr => $testaddr,
+                                  Timeout  => 3);
+if ($msock) {
+    plan tests => 7;
+} else {
+    plan skip_all => "No memcached instance running at $testaddr\n";
+    exit 0;
+}
+
+my $memd = Cache::Memcached->new({
+    servers   => [ $testaddr ],
+    namespace => "Cache::Memcached::t/$$/" . (time() % 100) . "/",
+});
+
+isa_ok($memd, 'Cache::Memcached');
+
+
+use constant count => 30;
+
+$memd->flush_all;
+
+$memd->add("key", "add");
+is($memd->get("key"), "add");
+
+for (my $i = 0; $i < count; ++$i) {
+    $memd->set("key", $i);
+}
+is($memd->get("key"), count - 1);
+
+$memd->replace("key", count);
+is($memd->get("key"), count);
+
+for (my $i = 0; $i < count; ++$i) {
+    $memd->incr("key", 2);
+}
+is($memd->get("key"), count + 2 * count);
+
+for (my $i = 0; $i < count; ++$i) {
+    $memd->decr("key", 1);
+}
+is($memd->get("key"), count + 1 * count);
+
+$memd->delete("key");
+is($memd->get("key"), undef);

Added: trunk/libcache-memcached-perl/t/05_reconnect_timeout.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcache-memcached-perl/t/05_reconnect_timeout.t?rev=35540&op=file
==============================================================================
--- trunk/libcache-memcached-perl/t/05_reconnect_timeout.t (added)
+++ trunk/libcache-memcached-perl/t/05_reconnect_timeout.t Sun May 17 03:25:04 2009
@@ -1,0 +1,28 @@
+#!/usr/bin/env perl -w
+
+use strict;
+use Test::More;
+use Cache::Memcached;
+use IO::Socket::INET;
+use Time::HiRes;
+
+my $testaddr = "192.0.2.1:11211";
+
+plan tests => 2;
+
+my $memd = Cache::Memcached->new({
+    servers   => [ $testaddr ],
+    namespace => "Cache::Memcached::t/$$/" . (time() % 100) . "/",
+});
+
+
+my $time1 = Time::HiRes::time();
+$memd->set("key", "bar");
+my $time2 = Time::HiRes::time();
+# 100ms is faster than the default connect timeout.
+ok($time2 - $time1 > .1, "Expected pause while connecting");
+
+# 100ms should be slow enough that dead socket reconnects happen faster than it.
+$memd->set("key", "foo");
+my $time3 = Time::HiRes::time();
+ok($time3 - $time2 < .1, "Should return fast on retry");

Added: trunk/libcache-memcached-perl/t/100_flush_bug.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcache-memcached-perl/t/100_flush_bug.t?rev=35540&op=file
==============================================================================
--- trunk/libcache-memcached-perl/t/100_flush_bug.t (added)
+++ trunk/libcache-memcached-perl/t/100_flush_bug.t Sun May 17 03:25:04 2009
@@ -1,0 +1,58 @@
+#!/usr/bin/env perl -w
+
+use strict;
+use Test::More;
+use Cache::Memcached;
+use IO::Socket::INET;
+
+my $testaddr = "127.0.0.1:11311";
+my $sock = IO::Socket::INET->new(
+    LocalAddr => $testaddr,
+    Proto     => 'tcp',
+    ReusAddr  => 1,
+);
+
+my @res = (
+    ["OK\r\n", 1],
+    ["ERROR\r\n", 0],
+    ["\r\nERROR\r\n", 0],
+    ["FOO\r\nERROR\r\n", 0],
+    ["FOO\r\nOK\r\nERROR\r\n", 0],
+    ["\r\n\r\nOK\r\n", 0],
+    ["END\r\n", 0],
+);
+
+if ($sock) {
+    plan tests => scalar @res;
+} else {
+    plan skip_all => "cannot bind to $testaddr\n";
+    exit 0;
+}
+close $sock;
+
+
+my $pid = fork;
+die "Cannot fork because: '$!'" unless defined $pid;
+unless ($pid) {
+    my $sock = IO::Socket::INET->new(
+        LocalAddr => $testaddr,
+        Proto     => 'tcp',
+        ReusAddr  => 1,
+        Listen    => 1,
+    ) or die "cannot open $testaddr: $!";
+    my $csock = $sock->accept();
+    while (defined (my $buf = <$csock>)) {
+        my $res = shift @res;
+        print $csock $res->[0];
+    }
+    close $csock;
+    close $sock;
+    exit 0;
+}
+
+my $memd = Cache::Memcached->new({ servers   => [ $testaddr ] });
+
+for (@res) {
+    ($_->[0] =~ s/\W//g);
+    is $memd->flush_all, $_->[1], $_->[0];
+}




More information about the Pkg-perl-cvs-commits mailing list