blib/lib/Dancer/Plugin/MemcachedFast.pm

filter: Statementstmt 45.4% 40 / 88 Branchbran 3.2% 2 / 62 Conditioncond 4.6% 2 / 43 MC/DCmcdc 0.0% 0 / 25 Subroutinesub 19.0% 4 / 21 Podpod n/a totaltotal 20.0% 48 / 239 CC 43 SCAR 32.4
CC
43
Cov
23%
__ANON__
42.0
__ANON__
42.0
__ANON__
42.0
CRAP 25.6
↑ Summary
1 package Dancer::Plugin::MemcachedFast;
2 3 $Dancer::Plugin::MemcachedFast::VERSION = '0.161360';
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # ABSTRACT: Dancer::Plugin::MemcachedFast - Cache things using Cache::Memcached::Fast
7  
8 3 ▶use Dancer::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶use Cache::Memcached::Fast;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 my $default_timeout = 3600;
13 3 my $ok_to_compress = 0;
14 3 my $cache = do {
15 3 my $config = plugin_setting;
16 $config->{servers} = [$ENV{HAVE_TEST_MEMCACHED_SERVER_LOCALHOST}]
17 3 ▶ if exists $ENV{HAVE_TEST_MEMCACHED_SERVER_LOCALHOST};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ENV{"HAVE_TEST_MEMCACHED_SERVER_LOCALHOST"} 0 3 3
18 $default_timeout = delete $config->{default_timeout}
19 3 ▶ if exists $config->{default_timeout};
Branch: 1 branch
BranchTrueFalseTotal
if exists $config->{"default_timeout"} 0 3 3
20 $ok_to_compress =
21 ( defined $config->{compress_threshold}
22 and int($config->{compress_threshold}) > 1
23 3 ▶ and defined $config->{compress_method});
Condition33%2/6
defined $config->{'compress_threshold'} && int $config->{'compress_threshold'} > 1 && defined $config->{'compress_method'}
!ll&&!rl&&r
300
defined $config->{"compress_threshold"} and int $config->{"compress_threshold"} > 1
!ll&&!rl&&r
300
MC/DC0%0/3
defined $config->{'compress_threshold'} && int $config->{'compress_threshold'} > 1 && defined $config->{'compress_method'}
defined $config->{"compress_threshold"} int $config->{"compress_threshold"} > 1 defined $config->{'compress_method'}
Truth table25%1/4
A and B && C
A= defined $config->{"compress_threshold"}B= int $config->{"compress_threshold"} > 1C= defined $config->{'compress_method'}
ABCresult
0XX0
10X0
1100
1111
24 3 Cache::Memcached::Fast->new($config);
25 };
26  
27 0 ▶register memcached_compress => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
28 0 ▶ unless ($ok_to_compress) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok_to_compress) 0 0 0
29 0 warn
30 "Cannot compress. Check the 'compress_threshold' and 'compress_method' configuration options";
31 0 return;
32 }
33 0 $cache->compress(!!$_[0]);
34 3 };
35  
36 0 ▶register memcached_get_or_set => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
37 0 ▶ $cache->get($_[0]) or do {
Branch: 1 branch
BranchTrueFalseTotal
$cache->get($_[0]) or do { my $ret; $cache->set($_[0], $ret = ref $_[1] eq "CODE" ? $_[1]->() : $_[1], defined $_[2] ? $_[2] : $default_timeout); $ret } or $_[1] 0 0 0
Condition0%0/3
$cache->get($_[0]) or do { my $ret; $cache->set($_[0], $ret = ref $_[1] eq "CODE" ? $_[1]->() : $_[1], defined $_[2] ? $_[2] : $default_timeout); $ret }
l!l&&r!l&&!r
000
MC/DC0%0/2
$cache->get($_[0]) or do { my $ret; $cache->set($_[0], $ret = ref $_[1] eq "CODE" ? $_[1]->() : $_[1], defined $_[2] ? $_[2] : $default_timeout); $ret }
$cache->get($_[0]) do { my $ret; $cache->set($_[0], $ret = ref $_[1] eq "CODE" ? $_[1]->() : $_[1], defined $_[2] ? $_[2] : $default_timeout); $ret }
Truth table0%0/3
A or B
A= $cache->get($_[0])B= do { my $ret; $cache->set($_[0], $ret = ref $_[1] eq "CODE" ? $_[1]->() : $_[1], defined $_[2] ? $_[2] : $default_timeout); $ret }
ABresult
1X1
011
000
38 0 my $ret;
39 0 ▶ $cache->set(
Branch: 2 branches
BranchTrueFalseTotal
ref $_[1] eq 'CODE' ? : 0 0 0
defined $_[2] ? : 0 0 0
40 $_[0],
41 $ret = ref $_[1] eq 'CODE' ? $_[1]->() : $_[1],
42 defined $_[2] ? $_[2] : $default_timeout
43 );
44 0 $ret;
45 }
46 or $_[1];
47 3 };
48  
49 0 ▶register memcached_get => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
50 0 ▶ return $cache->get($_[0]) if $#_ == 0 and !ref $_[0];
Branch: 1 branch
BranchTrueFalseTotal
if $#_ == 0 and not ref $_[0] 0 0 0
Condition0%0/3
$#_ == 0 and not ref $_[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$#_ == 0 and not ref $_[0]
$#_ == 0 not ref $_[0]
Truth table0%0/3
A and not(B)
A= $#_ == 0B= not ref $_[0]
ABresult
0X0
100
111
51 0 ▶ $cache->get_multi(map { ref $_ and ref $_ eq 'ARRAY' ? @$_ : $_ } @_);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 0 0
Condition0%0/3
ref $_ && (ref $_ eq 'ARRAY' ? @$_ : $_)
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_ && (ref $_ eq 'ARRAY' ? @$_ : $_)
ref $_ (ref $_ eq 'ARRAY' ? @$_ : $_)
Truth table0%0/3
A && B
A= ref $_B= (ref $_ eq 'ARRAY' ? @$_ : $_)
ABresult
0X0
100
111
52 3 };
53  
54 0 ▶register memcached_gets => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
55 0 ▶ return $cache->gets($_[0]) if $#_ == 0 and !ref $_[0];
Branch: 1 branch
BranchTrueFalseTotal
if $#_ == 0 and not ref $_[0] 0 0 0
Condition0%0/3
$#_ == 0 and not ref $_[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$#_ == 0 and not ref $_[0]
$#_ == 0 not ref $_[0]
Truth table0%0/3
A and not(B)
A= $#_ == 0B= not ref $_[0]
ABresult
0X0
100
111
56 0 ▶ $cache->gets_multi(map { ref $_ and ref $_ eq 'ARRAY' ? @$_ : $_ } @_);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 0 0
Condition0%0/3
ref $_ && (ref $_ eq 'ARRAY' ? @$_ : $_)
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_ && (ref $_ eq 'ARRAY' ? @$_ : $_)
ref $_ (ref $_ eq 'ARRAY' ? @$_ : $_)
Truth table0%0/3
A && B
A= ref $_B= (ref $_ eq 'ARRAY' ? @$_ : $_)
ABresult
0X0
100
111
57 3 };
58  
59 0 ▶register memcached_set => sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
60 0 ▶ return $cache->set(
Branch: 3 branches
BranchTrueFalseTotal
if ref $_[0] ne "ARRAY" 0 0 0
ref $_[1] eq 'CODE' ? : 0 0 0
defined $_[2] ? : 0 0 0
61 $_[0],
62 ref $_[1] eq 'CODE' ? $_[1]->() : $_[1],
63 defined $_[2] ? $_[2] : $default_timeout
64 ) if ref $_[0] ne 'ARRAY';
65 $cache->set_multi(
66 map { [
67 0 ▶ $_->[0],
Branch: 2 branches
BranchTrueFalseTotal
ref $_->[1] eq 'CODE' ? : 0 0 0
defined $_->[2] ? : 0 0 0
68 ref $_->[1] eq 'CODE' ? $_->[1]->() : $_->[1],
69 defined $_->[2] ? $_->[2] : $default_timeout
70 ]
71 0 } grep { ref $_ eq 'ARRAY' } @_
72 );
73 3 };
74  
75 0 ▶register memcached_add => sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
76 0 ▶ return $cache->add(
Branch: 3 branches
BranchTrueFalseTotal
if ref $_[0] ne "ARRAY" 0 0 0
ref $_[1] eq 'CODE' ? : 0 0 0
defined $_[2] ? : 0 0 0
77 $_[0],
78 ref $_[1] eq 'CODE' ? $_[1]->() : $_[1],
79 defined $_[2] ? $_[2] : $default_timeout
80 ) if ref $_[0] ne 'ARRAY';
81 $cache->add_multi(
82 map { [
83 0 ▶ $_->[0],
Branch: 2 branches
BranchTrueFalseTotal
ref $_->[1] eq 'CODE' ? : 0 0 0
defined $_->[2] ? : 0 0 0
84 ref $_->[1] eq 'CODE' ? $_->[1]->() : $_->[1],
85 defined $_->[2] ? $_->[2] : $default_timeout
86 ]
87 0 } grep { ref $_ eq 'ARRAY' } @_
88 );
89 3 };
90  
91 0 ▶register memcached_replace => sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
92 0 ▶ return $cache->replace(
Branch: 3 branches
BranchTrueFalseTotal
if ref $_[0] ne "ARRAY" 0 0 0
ref $_[1] eq 'CODE' ? : 0 0 0
defined $_[2] ? : 0 0 0
93 $_[0],
94 ref $_[1] eq 'CODE' ? $_[1]->() : $_[1],
95 defined $_[2] ? $_[2] : $default_timeout
96 ) if ref $_[0] ne 'ARRAY';
97 $cache->replace_multi(
98 map { [
99 0 ▶ $_->[0],
Branch: 2 branches
BranchTrueFalseTotal
ref $_->[1] eq 'CODE' ? : 0 0 0
defined $_->[2] ? : 0 0 0
100 ref $_->[1] eq 'CODE' ? $_->[1]->() : $_->[1],
101 defined $_->[2] ? $_->[2] : $default_timeout
102 ]
103 0 } grep { ref $_ eq 'ARRAY' } @_
104 );
105 3 };
106  
107 0 ▶register memcached_delete => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
108 0 ▶ return $cache->delete($_[0]) if $#_ == 0 and !ref $_[0];
Branch: 1 branch
BranchTrueFalseTotal
if $#_ == 0 and not ref $_[0] 0 0 0
Condition0%0/3
$#_ == 0 and not ref $_[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$#_ == 0 and not ref $_[0]
$#_ == 0 not ref $_[0]
Truth table0%0/3
A and not(B)
A= $#_ == 0B= not ref $_[0]
ABresult
0X0
100
111
109 0 ▶ $cache->delete_multi(map { (ref $_ and ref $_ eq 'ARRAY') ? @$_ : $_ } @_);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ && ref $_ eq 'ARRAY' ? : 0 0 0
Condition0%0/3
ref $_ and ref $_ eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_ and ref $_ eq "ARRAY"
ref $_ ref $_ eq "ARRAY"
Truth table0%0/3
A and B
A= ref $_B= ref $_ eq "ARRAY"
ABresult
0X0
100
111
110 3 };
111  
112 0 ▶register memcached_append => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
113 0 ▶ return $cache->append(@_) if ($#_ == 1 and !ref $_[0] and !ref $_[1]);
Branch: 1 branch
BranchTrueFalseTotal
if $#_ == 1 and not ref $_[0] and not ref $_[1] 0 0 0
Condition0%0/6
$#_ == 1 and not ref $_[0] and not ref $_[1]
!ll&&!rl&&r
000
$#_ == 1 and not ref $_[0]
!ll&&!rl&&r
000
MC/DC0%0/3
$#_ == 1 and not ref $_[0] and not ref $_[1]
$#_ == 1 not ref $_[0] not ref $_[1]
Truth table0%0/4
A and not(B) and not(C)
A= $#_ == 1B= not ref $_[0]C= not ref $_[1]
ABCresult
0XX0
10X0
1100
1111
114 0 $cache->append_multi(grep { ref $_ eq 'ARRAY' } @_);
115 3 };
116  
117 0 ▶register memcached_prepend => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
118 0 ▶ return $cache->prepend(@_) if ($#_ == 1 and !ref $_[0] and !ref $_[1]);
Branch: 1 branch
BranchTrueFalseTotal
if $#_ == 1 and not ref $_[0] and not ref $_[1] 0 0 0
Condition0%0/6
$#_ == 1 and not ref $_[0] and not ref $_[1]
!ll&&!rl&&r
000
$#_ == 1 and not ref $_[0]
!ll&&!rl&&r
000
MC/DC0%0/3
$#_ == 1 and not ref $_[0] and not ref $_[1]
$#_ == 1 not ref $_[0] not ref $_[1]
Truth table0%0/4
A and not(B) and not(C)
A= $#_ == 1B= not ref $_[0]C= not ref $_[1]
ABCresult
0XX0
10X0
1100
1111
119 0 $cache->prepend_multi(grep { ref $_ eq 'ARRAY' } @_);
120 3 };
121  
122 0 ▶register memcached_incr => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
123 0 ▶ return $cache->incr(@_) if ($#_ <= 2 and scalar grep { !ref $_ } @_);
Branch: 1 branch
BranchTrueFalseTotal
if $#_ <= 2 and scalar grep({not ref $_;} @_) 0 0 0
Condition0%0/2
$#_ <= 2 and scalar grep({not ref $_;} @_)
!ll
00
MC/DC0%0/1
$#_ <= 2 and scalar grep({not ref $_;} @_)
$#_ <= 2
Truth table0%0/2
A
A= $#_ <= 2
Aresult
00
11
124 0 $cache->incr_multi(grep { ref $_ eq 'ARRAY' } @_);
125 3 };
126  
127 0 ▶register memcached_decr => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
128 0 ▶ return $cache->decr(@_) if ($#_ <= 2 and scalar grep { !ref $_ } @_);
Branch: 1 branch
BranchTrueFalseTotal
if $#_ <= 2 and scalar grep({not ref $_;} @_) 0 0 0
Condition0%0/2
$#_ <= 2 and scalar grep({not ref $_;} @_)
!ll
00
MC/DC0%0/1
$#_ <= 2 and scalar grep({not ref $_;} @_)
$#_ <= 2
Truth table0%0/2
A
A= $#_ <= 2
Aresult
00
11
129 0 $cache->decr_multi(grep { ref $_ eq 'ARRAY' } @_);
130 3 };
131  
132 0 ▶register memcached_flush_all => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
133 0 $cache->flush_all(@_);
134 3 };
135  
136 0 ▶register memcached_nowait_push => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
137 0 $cache->nowait_push;
138 3 };
139  
140 0 ▶register memcached_server_versions => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
141 0 $cache->server_versions;
142 3 };
143  
144 0 ▶register memcached_disconnect_all => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
145 0 $cache->disconnect_all;
146 3 };
147  
148 0 ▶register memcached_namespace => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
149 0 $cache->namespace($_[0]);
150 3 };
151  
152 3 register_plugin;
153  
154 3 1;
155  
156 __END__
↑ Summary