blib/lib/MemcacheDBI.pm

filter: Statementstmt 35.8% 58 / 162 Branchbran 20.9% 13 / 62 Conditioncond 13.7% 4 / 29 MC/DCmcdc 0.0% 0 / 17 Subroutinesub 40.0% 12 / 30 Podpod 100% 5 / 5 totaltotal 30.1% 92 / 305 CC 44 SCAR 32.0
CC
44
Cov
30%
memd_init
110.0
commit
30.0
rollback
30.0
CRAP 24.5
↑ Summary
1 package MemcacheDBI;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use Clone;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use vars qw( $AUTOLOAD $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 $VERSION = '0.08';
8 3 require 5.10.0;
9  
10 3 our $DEBUG;
11 3 our $me = '[MemcacheDBI]';
12  
13 =head1 NAME
14  
15 MemcacheDBI - Queue memcache calls when in a dbh transaction
16  
17 =head1 SYNOPSYS
18  
19 MemcacheDBI is a drop in replacement for DBI. It allows you to do trivial caching of some objects in a somewhat transactionally safe manner.
20  
21 use MemcacheDBI;
22 my $dbh = MemcacheDBI->connect($data_source, $user, $password, {} ); # just like DBI
23 $dbh->memd_init(\%memcache_connection_args) # see Cache::Memcached::Fast
24  
25 # Cache::Memcached::Fast should work using these calls
26 $dbh->memd->get();
27 $dbh->memd->set();
28 $memd = $dbh->memd; #get a handle you can use wherever
29  
30 # DBI methods should all work as normal. Additional new methods listed below
31 $dbh->prepare();
32 $dbh->execute();
33 etc
34  
35 =head1 DESCRIPTION
36  
37 Attach your memcached to your DBH handle. By doing so we can automatically queue set/get calls so that they happen at the same time as a commit. If a rollback is issued then the queue will be cleared.
38  
39 =head1 CAVEATS
40  
41 As long as DBI and Memcache are both up and running your fine. However this module will experience race conditions when one or the other goes down. We are currently working to see if some of this can be minimized, but be aware it is impossible to protect you if the DB/Memcache servers go down.
42  
43 =head1 METHODS
44  
45 =head2 memd_init
46  
47 Normally you would use a MemcacheDBI->connect to create a new handle. However if you already have a DBH handle you can use this method to create a MemcacheDBI object using your existing handle.
48  
49 Accepts a the following data types
50  
51 Cache::Memcached::Fast (new Cache::Memcached::Fast)
52 A DBI handle (DBI->connect)
53 HASH of arguments to pass to new Cache::Memcached::Fast
54  
55 =cut
56  
57 0 ▶sub memd_init {
Subroutine memd_init: not called CC=10 SCAR=47.0
Pod documented
58 0 ▶ warn "[debug $DEBUG]$me->memd_init\n" if $DEBUG && $DEBUG > 3;
Branch: 1 branch
BranchTrueFalseTotal
if $MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 3 0 0 0
Condition0%0/3
$MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 3
!ll&&!rl&&r
000
MC/DC0%0/2
$MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 3
$MemcacheDBI::DEBUG $MemcacheDBI::DEBUG > 3
Truth table0%0/3
A and B
A= $MemcacheDBI::DEBUGB= $MemcacheDBI::DEBUG > 3
ABresult
0X0
100
111
59 0 my $class = shift;
60 0 ▶ my $node = ref $class ? $class : do{ tie my %node, 'MemcacheDBI::Tie'; warn 'whee'; \%node; };
Branch: 1 branch
BranchTrueFalseTotal
ref $class ? : 0 0 0
61 0 ▶ while (my $handle = shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $handle = shift()) 0 0 0
62 0 ▶ if (ref $handle eq 'DBI::db') {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $handle eq 'DBI::db') { } 0 0 0
elsif (ref $handle eq 'Cache::Memcached::Fast') { } 0 0 0
elsif (ref $handle eq 'HASH') { } 0 0 0
63 0 $node->{'MemcacheDBI'}->{'dbh'} = $handle;
64 } elsif (ref $handle eq 'Cache::Memcached::Fast') {
65 0 $node->{'MemcacheDBI'}->{'memd'} = MemcacheDBI::Memd->memd_init($node,$handle);
66 } elsif (ref $handle eq 'HASH') {
67 0 $node->{'MemcacheDBI'}->{'memd'} = MemcacheDBI::Memd->memd_init($node,$handle);
68 } else {
69 0 die 'Unknown ref type'.do{my @c = caller; ' at '.$c[1].' line '.$c[2]."\n" };
70 }
71 }
72 0 ▶ if (! ref $class) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $class) 0 0 0
73 0 ▶ return unless $node->{'MemcacheDBI'}->{'dbh'};
Branch: 1 branch
BranchTrueFalseTotal
unless $node->{"MemcacheDBI"}{"dbh"} 0 0 0
74 0 return bless $node, $class;
75 }
76 0 return $class;
77 }
78  
79 =head2 memd
80  
81 Get a memcache object that supports get/set/transactions
82  
83 =cut
84  
85 0 ▶sub memd {
Subroutine memd: not called CC=1 SCAR=6.9
Pod documented
86 0 shift->{'MemcacheDBI'}->{'memd'};
87 }
88  
89 =head1 DBI methods can also be used, including but not limited to:
90  
91 =head2 connect
92  
93 The same as DBI->connect, returns a MemcacheDBI object so you can get your additional memcache functionality
94  
95 =cut
96  
97 3 ▶sub connect {
Subroutine connect: called CC=5 SCAR=16.6
Pod documented
98 3 ▶ warn "[debug $DEBUG]$me->connect\n" if $DEBUG && $DEBUG > 3;
Branch: 1 branch
BranchTrueFalseTotal
if $MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 3 0 3 3
Condition33%1/3
$MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 3
!ll&&!rl&&r
300
MC/DC0%0/2
$MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 3
$MemcacheDBI::DEBUG $MemcacheDBI::DEBUG > 3
Truth table33%1/3
A and B
A= $MemcacheDBI::DEBUGB= $MemcacheDBI::DEBUG > 3
ABresult
0X0
100
111
99 3 my $class = shift;
100 3 tie my %node, 'MemcacheDBI::Tie';
101 3 ▶ eval{ $node{'MemcacheDBI'}->{'dbh'} = DBI->connect(@_) } or die $@.do{my @c = caller; ' at '.$c[1].' line '.$c[2]."\n" };
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $node{"MemcacheDBI"}{"dbh"} = "DBI"->connect(@_) } } or die $@ . do { my(@c) = caller; ' at ' . $c[1] . ' line ' . $c[2] . "\n" } 2 1 3
102 2 ▶ return unless $node{'MemcacheDBI'}->{'dbh'};
Branch: 1 branch
BranchTrueFalseTotal
unless $node{"MemcacheDBI"}{"dbh"} 0 2 2
103 2 return bless \%node, $class;
104 }
105  
106 =head2 commit
107  
108 The same as DBI->commit, however it will also commit the memcached queue
109  
110 =cut
111  
112 0 ▶sub commit {
Subroutine commit: not called CC=5 SCAR=34.0
Pod documented
113 0 ▶ warn "[debug $DEBUG]$me->commit\n" if $DEBUG && $DEBUG > 3;
Branch: 1 branch
BranchTrueFalseTotal
if $MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 3 0 0 0
Condition0%0/3
$MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 3
!ll&&!rl&&r
000
MC/DC0%0/2
$MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 3
$MemcacheDBI::DEBUG $MemcacheDBI::DEBUG > 3
Truth table0%0/3
A and B
A= $MemcacheDBI::DEBUGB= $MemcacheDBI::DEBUG > 3
ABresult
0X0
100
111
114 0 my $self = shift;
115 # TODO handle rolling back the memcache stuff if dbh fails
116 0 ▶ warn 'Commit ineffective while AutoCommit is on'.do{my @c = caller; ' at '.$c[1].' line '.$c[2]."\n" } if $self->{'AutoCommit'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"AutoCommit"} 0 0 0
117 0 my $memd = $self->memd;
118 0 ▶ $memd->commit if $memd;
Branch: 1 branch
BranchTrueFalseTotal
if $memd 0 0 0
119 0 $self->{'MemcacheDBI'}->{'dbh'}->commit(@_);
120 }
121  
122 =head2 rollback
123  
124 The same as DBI->rollback, however it will also rollback the memcached queue
125  
126 =cut
127  
128 0 ▶sub rollback {
Subroutine rollback: not called CC=5 SCAR=34.0
Pod documented
129 0 ▶ warn "[debug $DEBUG]$me->rollback\n" if $DEBUG && $DEBUG > 3;
Branch: 1 branch
BranchTrueFalseTotal
if $MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 3 0 0 0
Condition0%0/3
$MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 3
!ll&&!rl&&r
000
MC/DC0%0/2
$MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 3
$MemcacheDBI::DEBUG $MemcacheDBI::DEBUG > 3
Truth table0%0/3
A and B
A= $MemcacheDBI::DEBUGB= $MemcacheDBI::DEBUG > 3
ABresult
0X0
100
111
130 0 my $self = shift;
131 0 ▶ warn 'rollback ineffective with AutoCommit enabled'.do{my @c = caller; ' at '.$c[1].' line '.$c[2]."\n" } if $self->{'AutoCommit'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"AutoCommit"} 0 0 0
132 0 my $memd = $self->memd;
133 0 ▶ $memd->rollback if $memd;
Branch: 1 branch
BranchTrueFalseTotal
if $memd 0 0 0
134 0 $self->{'MemcacheDBI'}->{'dbh'}->rollback(@_);
135 }
136  
137 5 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=4 SCAR=14.1
138 5 my $self = shift;
139 5 my($field)=$AUTOLOAD;
140 5 $field =~ s/.*://;
141 5 my $method = (ref $self).'::'.$field;
142 5 ▶ warn "[debug $DEBUG]$me create autoload for $method\n" if $DEBUG && $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 1 0 5 5
Condition33%1/3
$MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 1
!ll&&!rl&&r
500
MC/DC0%0/2
$MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 1
$MemcacheDBI::DEBUG $MemcacheDBI::DEBUG > 1
Truth table33%1/3
A and B
A= $MemcacheDBI::DEBUGB= $MemcacheDBI::DEBUG > 1
ABresult
0X0
100
111
143 3 ▶ no strict 'refs'; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
144 6 ▶ *$method = sub {
Subroutine __ANON__: called CC=4 SCAR=14.3
145 6 my $self = shift;
146 6 ▶ warn "[debug $DEBUG]${me}->{'dbh'}->$field\n" if $DEBUG && $DEBUG > 3;
Branch: 1 branch
BranchTrueFalseTotal
if $MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 3 0 6 6
Condition33%1/3
$MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 3
!ll&&!rl&&r
600
MC/DC0%0/2
$MemcacheDBI::DEBUG and $MemcacheDBI::DEBUG > 3
$MemcacheDBI::DEBUG $MemcacheDBI::DEBUG > 3
Truth table33%1/3
A and B
A= $MemcacheDBI::DEBUGB= $MemcacheDBI::DEBUG > 3
ABresult
0X0
100
111
147 6 ▶ die 'Can\'t locate object method "'.$field.'" via package "'.(ref $self->{'MemcacheDBI'}->{'dbh'}).'"'.do{my @c = caller; ' at '.$c[1].' line '.$c[2]."\n" } unless $self->{'MemcacheDBI'}->{'dbh'}->can($field);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"MemcacheDBI"}{"dbh"}->can($field) 1 5 6
148 5 $self->{'MemcacheDBI'}->{'dbh'}->$field(@_);
149 5 };
150 5 ▶ die 'Can\'t locate object method "'.$field.'" via package "'.(ref $self->{'MemcacheDBI'}->{'dbh'}).'"'.do{my @c = caller; ' at '.$c[1].' line '.$c[2]."\n" } unless $self->{'MemcacheDBI'}->{'dbh'}->can($field);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"MemcacheDBI"}{"dbh"}->can($field) 1 4 5
151 4 $self->$field(@_);
152 }
153  
154 package MemcacheDBI::Memd;
155  
156 0 ▶sub memd_init {
Subroutine memd_init: not called CC=2 SCAR=17.9
157 0 my $class = shift;
158 0 my $dbh = shift;
159 0 my $handle = shift;
160 0 tie my %node, 'MemcacheDBI::Tie', 'memd';
161 0 require Cache::Memcached::Fast;
162 0 ▶ $handle = Cache::Memcached::Fast->new($handle) if ref $handle eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $handle eq "HASH" 0 0 0
163 0 $node{'MemcacheDBI'}{'memd'} = $handle;
164 0 $node{'MemcacheDBI'}{'dbh'} = $dbh; # careful, circular
165 0 return bless \%node, $class;
166 }
167  
168 0 ▶sub get {
Subroutine get: not called CC=3 SCAR=24.8
169 0 my ($self,$key) = @_;
170 0 ▶ return if $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue_delete'}->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"MemcacheDBI"}{"dbh"}{"MemcacheDBI"}{"queue_delete"}{$key} 0 0 0
171 0 ▶ if (exists $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue'}->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"MemcacheDBI"}{"dbh"}{"MemcacheDBI"}{"queue"}{$key}) 0 0 0
172 0 return $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue'}->{$key};
173 }
174 0 $self->{'MemcacheDBI'}->{'memd'}->get($key);
175 }
176  
177 0 ▶sub set {
Subroutine set: not called CC=2 SCAR=17.9
178 0 my ($self,$key,$value) = @_;
179 0 delete $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue_delete'}->{$key};
180 0 ▶ if ($self->{'MemcacheDBI'}->{'dbh'}->{'AutoCommit'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"MemcacheDBI"}{"dbh"}{"AutoCommit"}) 0 0 0
181 0 delete $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue'}->{$key};
182 0 return $self->{'MemcacheDBI'}->{'memd'}->set($key, $value);
183 }
184 0 $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue'}->{$key} = Clone::clone($value);
185 0 1;
186 }
187  
188 0 ▶sub delete {
Subroutine delete: not called CC=3 SCAR=24.8
189 0 my ($self,$key) = @_;
190 0 ▶ if ($self->{'MemcacheDBI'}->{'dbh'}->{'AutoCommit'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"MemcacheDBI"}{"dbh"}{"AutoCommit"}) 0 0 0
191 0 delete $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue_delete'}->{$key};
192 0 delete $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue'}->{$key};
193 0 return $self->{'MemcacheDBI'}->{'memd'}->delete($key);
194 }
195 0 my $val = $self->get($key);
196 0 delete $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue'}->{$key};
197 0 $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue_delete'}->{$key} = 1;
198 0 ▶ $val ? 1 : '';
Branch: 1 branch
BranchTrueFalseTotal
$val ? : 0 0 0
199 }
200 0 ▶sub remove { shift->delete(@_); }
Subroutine remove: not called CC=1 SCAR=6.9
201  
202 0 ▶sub namespace {
Subroutine namespace: not called CC=5 SCAR=34.0
203 0 my $self = shift;
204 0 ▶ if (scalar @_ && !$self->{'MemcacheDBI'}->{'dbh'}->{'AutoCommit'} && (
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ and not $self->{"MemcacheDBI"}{"dbh"}{"AutoCommit"} and $self->{"MemcacheDBI"}{"dbh"}{"MemcacheDBI"}{"queue_delete"} || $self->{"MemcacheDBI"}{"dbh"}{"MemcacheDBI"}{"queue"}) 0 0 0
Condition0%0/9
scalar @_ and not $self->{"MemcacheDBI"}{"dbh"}{"AutoCommit"} and $self->{"MemcacheDBI"}{"dbh"}{"MemcacheDBI"}{"queue_delete"} || $self->{"MemcacheDBI"}{"dbh"}{"MemcacheDBI"}{"queue"}
!ll&&!rl&&r
000
scalar @_ and not $self->{"MemcacheDBI"}{"dbh"}{"AutoCommit"}
!ll&&!rl&&r
000
$self->{"MemcacheDBI"}{"dbh"}{"MemcacheDBI"}{"queue_delete"} or $self->{"MemcacheDBI"}{"dbh"}{"MemcacheDBI"}{"queue"}
l!l&&r!l&&!r
000
MC/DC0%0/4
scalar @_ and not $self->{"MemcacheDBI"}{"dbh"}{"AutoCommit"} and $self->{"MemcacheDBI"}{"dbh"}{"MemcacheDBI"}{"queue_delete"} || $self->{"MemcacheDBI"}{"dbh"}{"MemcacheDBI"}{"queue"}
scalar @_ not $self->{"MemcacheDBI"}{"dbh"}{"AutoCommit"} $self->{"MemcacheDBI"}{"dbh"}{"MemcacheDBI"}{"queue_delete"} $self->{"MemcacheDBI"}{"dbh"}{"MemcacheDBI"}{"queue"}
Truth table0%0/5
A and not(B) and C or D
A= scalar @_B= not $self->{"MemcacheDBI"}{"dbh"}{"AutoCommit"}C= $self->{"MemcacheDBI"}{"dbh"}{"MemcacheDBI"}{"queue_delete"}D= $self->{"MemcacheDBI"}{"dbh"}{"MemcacheDBI"}{"queue"}
ABCDresult
0XXX0
10XX0
11000
111X1
11011
205 $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue_delete'}
206 || $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue'}
207 )) {
208 0 die 'Cannot set namespace during a transaction'.do{my @c = caller; ' at '.$c[1].' line '.$c[2]."\n" };
209 }
210 0 $self->{'MemcacheDBI'}->{'memd'}->namespace(@_);
211 }
212  
213 0 ▶sub server_versions { shift->{'MemcacheDBI'}->{'memd'}->server_versions(@_); }
Subroutine server_versions: not called CC=1 SCAR=6.9
214  
215 # do not confuse this with DBH commits
216 0 ▶sub commit {
Subroutine commit: not called CC=3 SCAR=24.8
217 0 my ($self) = @_;
218 0 my $queue = $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue'};
219 0 foreach my $key (keys %$queue) {
220 0 $self->{'MemcacheDBI'}->{'memd'}->set($key, $queue->{$key});
221 }
222 0 delete $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue'};
223  
224 0 $queue = $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue_delete'};
225 0 foreach my $key (keys %$queue) {
226 0 $self->{'MemcacheDBI'}->{'memd'}->delete($key);
227 }
228 0 delete $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue_delete'};
229  
230 0 return 1;
231 }
232  
233 0 ▶sub rollback {
Subroutine rollback: not called CC=1 SCAR=6.9
234 0 my ($self) = @_;
235 0 delete $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue'};
236 0 delete $self->{'MemcacheDBI'}->{'dbh'}->{'MemcacheDBI'}->{'queue_delete'};
237  
238 0 return 1;
239 }
240  
241 package MemcacheDBI::Tie;
242  
243 # passes all calls to the parent $tie_type unless the key is MemcacheDBI
244 # allows me to wrap my data in a container while somewhat preseving the parents operation
245  
246 3 ▶sub TIEHASH {
Subroutine TIEHASH: called CC=2 SCAR=7.1
247 3 my $class = shift;
248 3 ▶ my $tie_type = shift || 'dbh'; # dbh or memd
Condition50%1/2
shift() || 'dbh'
l!l
03
MC/DC0%0/1
shift() || 'dbh'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
249 3 return bless {MemcacheDBI=>{tie_type=>$tie_type}}, $class;
250 }
251  
252 26 ▶sub FETCH {
Subroutine FETCH: called CC=2 SCAR=6.9
253 26 my ($self,$key) = @_;
254 26 my $short = $self->{'MemcacheDBI'};
255 26 ▶ return $short if $key eq 'MemcacheDBI';
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "MemcacheDBI" 25 1 26
256 1 $short->{$short->{'tie_type'}}->{$key};
257 }
258  
259 0 ▶sub STORE {
Subroutine STORE: not called CC=1 SCAR=6.9
260 0 my ($self,$key,$value) = @_;
261 0 my $short = $self->{'MemcacheDBI'};
262 0 $short->{$short->{'tie_type'}}->{$key} = $value;
263 }
264  
265 0 ▶sub DELETE {
Subroutine DELETE: not called CC=2 SCAR=17.9
266 0 my ($self,$key) = @_;
267 0 ▶ die 'Cannot delete MemcacheDBI'.do{my @c = caller; ' at '.$c[1].' line '.$c[2]."\n" } if $key eq 'MemcacheDBI';
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "MemcacheDBI" 0 0 0
268 0 my $short = $self->{'MemcacheDBI'};
269 0 delete $short->{$short->{'tie_type'}}->{$key};
270 }
271  
272 0 ▶sub CLEAR {
Subroutine CLEAR: not called CC=1 SCAR=6.9
273 0 my ($self) = @_;
274 }
275  
276 1 ▶sub FIRSTKEY {
Subroutine FIRSTKEY: called CC=2 SCAR=8.4
277 1 my ($self) = @_;
278 1 my $tmp = $self->{'MemcacheDBI'}->{$self->{'MemcacheDBI'}->{'tie_type'}};
279 1 ▶ return unless ref $tmp eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $tmp eq "HASH" 1 0 1
280 0 keys %$tmp;
281 0 return scalar each %$tmp;
282 }
283  
284 0 ▶sub NEXTKEY {
Subroutine NEXTKEY: not called CC=1 SCAR=6.9
285 0 my ($self) = @_;
286 0 my $tmp = $self->{'MemcacheDBI'}->{$self->{'MemcacheDBI'}->{'tie_type'}};
287 0 return scalar each %$tmp;
288 }
289  
290 0 ▶sub EXISTS {
Subroutine EXISTS: not called CC=1 SCAR=6.9
291 0 my ($self,$key) = @_;
292 0 return exists $self->{'MemcacheDBI'}->{$self->{'MemcacheDBI'}->{'tie_type'}}->{$key};
293 }
294  
295 3 1;
296  
297 =head1 REPOSITORY
298  
299 The code is available on github:
300  
301 https://github.com/oaxlin/MemcacheDBI.git
302  
303 =head1 DISCLAIMER
304  
305 THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
306 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
307 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
308  
↑ Summary