blib/lib/Magpie/Component/ContentCache.pm

filter: Statementstmt 40.0% 10 / 25 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 50.0% 2 / 4 Podpod 0.0% 0 / 2 totaltotal 30.0% 12 / 40 CC 5 SCAR 29.6
CC
5
Cov
30%
cache_content
30.0
load_queue
2.0
BEGIN
1.0
CRAP 19.2
« blib/lib/Magpie/Resource/DBIC.pm ↑ Summary lib/Magpie/Resource/Kioku.pm »
1 package Magpie::Component::ContentCache;
2 # ABSTRACT: Internally added content cache component
3 1 $Magpie::Component::ContentCache::VERSION = '1.163200';
4 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 extends 'Magpie::Transformer';
6 1 ▶use Magpie::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 __PACKAGE__->register_events( qw(cache_content));
9  
10 0 ▶sub load_queue { return qw( cache_content ) }
Subroutine load_queue: not called CC=1 SCAR=6.9
Pod undocumented
11  
12  
13 0 ▶sub cache_content {
Subroutine cache_content: not called CC=5 SCAR=34.0
Pod undocumented
14 0 my $self = shift;
15 0 my $ctxt = shift;
16 0 ▶ return OK unless $self->resource->can('cache');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->resource->can("cache") 0 0 0
17 0 ▶ return OK if $self->has_error;
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_error 0 0 0
18 0 my $content = undef;
19 0 my $uri = $self->request->uri->as_string;
20 0 my $cache = $self->resource->cache;
21  
22 0 ▶ if ($self->resource->has_data) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->resource->has_data) { } 0 0 0
23 0 $content = $self->resource->data;
24 }
25 else {
26 0 $content = $self->response->body;
27 }
28  
29 0 ▶ my $cached = $cache->get($uri) || {};
Condition0%0/2
$cache->get($uri) || {}
l!l
00
MC/DC0%0/1
$cache->get($uri) || {}
$cache->get($uri)
Truth table0%0/2
A
A= $cache->get($uri)
Aresult
11
00
30 0 $cached->{content} = $content;
31 0 $cache->set($uri, $cached);
32 0 return OK;
33 }
34  
35 # SEEALSO: Magpie
36  
37 1 1;
38  
39 __END__
« blib/lib/Magpie/Resource/DBIC.pm ↑ Summary lib/Magpie/Resource/Kioku.pm »