WithCache/Backend/Cache/FileCache.pm

filter: Statementstmt 93.5% 29 / 31 Branchbran 75.0% 3 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 85.1% 40 / 47 CC 4 SCAR 8.7
CC
4
Cov
87%
__ANON__
4.5
__ANON__
1.0
BEGIN
1.0
CRAP 2.4
« WithCache/Backend.pm ↑ Summary WithCache.pm »
1  
2 package MooseX::WithCache::Backend::Cache::FileCache;
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 extends 'MooseX::WithCache::Backend';
7  
8 1 class_type 'Cache::FileCache';
9  
10 1 ▶sub _build_cache_type {
Subroutine _build_cache_type: called CC=1 SCAR=0.0
11 1 return 'Cache::FileCache';
12 }
13  
14 1 ▶around _build_methods => sub {
Subroutine __ANON__: called CC=1 SCAR=0.2
15 1 my ($next, $self) = @_;
16  
17 1 my $methods = $next->($self);
18 4 ▶ $methods->{cache_del} = sub {
Subroutine __ANON__: called CC=4 SCAR=15.0
19 4 my ($self, $key) = @_;
20 4 my $cache = $self->__get_cache();
21 4 ▶ if ($self->cache_disabled || ! $cache) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->cache_disabled or not $cache) 0 4 4
Condition33%1/3
$self->cache_disabled or not $cache
l!l&&r!l&&!r
004
MC/DC0%0/2
$self->cache_disabled or not $cache
$self->cache_disabled not $cache
Truth table33%1/3
A or not(B)
A= $self->cache_disabledB= not $cache
ABresult
1X1
011
000
22 0 if (MooseX::WithCache::DEBUG()) {
23 $self->cache_debug("cache_set: Cache disabled");
24 }
25 0 return ();
26 }
27  
28 4 my $keygen = $self->cache_key_generator;
29 4 ▶ my $cache_key = $keygen ? $keygen->generate($key) : $key;
Branch: 1 branch
BranchTrueFalseTotal
$keygen ? : 2 2 4
30 4 if (MooseX::WithCache::DEBUG()) {
31 $self->cache_debug(
32 "cache_del: key =",
33 ($cache_key || '(null)'),
34 );
35 }
36 4 return $cache->remove($cache_key);
37 1 };
38 1 return $methods;
39 1 };
40  
41 1 __PACKAGE__->meta->make_immutable;
42  
43 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 1 ▶no Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 1 1;
47  
48 __END__
« WithCache/Backend.pm ↑ Summary WithCache.pm »