File: 04_noreply.t

package info (click to toggle)
libcache-memcached-perl 1.30-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 184 kB
  • sloc: perl: 1,101; makefile: 3
file content (52 lines) | stat: -rw-r--r-- 1,074 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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);