Mercurial > hg > Cache-Memcached
comparison t/02_keys.t @ 0:17fc6afc155e CACHE_MEMCACHED_1_24
Cache::Memcached 1.24
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sun, 30 Sep 2007 16:23:31 +0400 |
parents | |
children | f5cfb726ea65 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:17fc6afc155e |
---|---|
1 # -*-perl-*- | |
2 | |
3 use strict; | |
4 use Test::More; | |
5 use Cache::Memcached; | |
6 use IO::Socket::INET; | |
7 | |
8 my $testaddr = "127.0.0.1:11211"; | |
9 my $msock = IO::Socket::INET->new(PeerAddr => $testaddr, | |
10 Timeout => 3); | |
11 if ($msock) { | |
12 plan tests => 10; | |
13 } else { | |
14 plan skip_all => "No memcached instance running at $testaddr\n"; | |
15 exit 0; | |
16 } | |
17 | |
18 my $memd = Cache::Memcached->new({ | |
19 servers => [ $testaddr ], | |
20 namespace => "Cache::Memcached::t/$$/" . (time() % 100) . "/", | |
21 }); | |
22 | |
23 | |
24 ok($memd->set("key1", "val1"), "set succeeded"); | |
25 | |
26 is($memd->get("key1"), "val1", "get worked"); | |
27 ok(! $memd->add("key1", "val-replace"), "add properly failed"); | |
28 ok($memd->add("key2", "val2"), "add worked on key2"); | |
29 is($memd->get("key2"), "val2", "get worked"); | |
30 | |
31 ok($memd->replace("key2", "val-replace"), "replace worked"); | |
32 ok(! $memd->replace("key-noexist", "bogus"), "replace failed"); | |
33 | |
34 my $stats = $memd->stats; | |
35 ok($stats, "got stats"); | |
36 is(ref $stats, "HASH", "is a hashref"); | |
37 | |
38 | |
39 # also make one without a hashref | |
40 my $mem2 = Cache::Memcached->new( | |
41 servers => [ ], | |
42 debug => 1, | |
43 ); | |
44 ok($mem2->{debug}, "debug is set on alt constructed instance"); |