| 1 | package Magpie::Component::ContentCache; | ||||||||||||
| 2 | # ABSTRACT: Internally added content cache component | ||||||||||||
| 3 | 1 | $Magpie::Component::ContentCache::VERSION = '1.141660'; | |||||||||||
| 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 | sub cache_content { | ||||||||||||
| 14 | 0 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
cache_content: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||
| 15 | 0 | my $ctxt = shift; | |||||||||||
| 16 | 0 | ▶ | return OK unless $self->resource->can('cache'); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 17 | 0 | ▶ | return OK if $self->has_error; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 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) || {}
MC/DC0%0/1
$cache->get($uri) || {}
$cache->get($uri)
Truth table0%0/2
A
A= $cache->get($uri)
| |||||||||||||
| 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__ | ||||||||||||
| 40 | =pod | ||||||||||||
| 41 | |||||||||||||
| 42 | =head1 NAME | ||||||||||||
| 43 | |||||||||||||
| 44 | Magpie::Component::ContentCache - Internally added content cache component | ||||||||||||
| 45 | |||||||||||||
| 46 | =head1 VERSION | ||||||||||||
| 47 | |||||||||||||
| 48 | version 1.141660 | ||||||||||||
| 49 | |||||||||||||
| 50 | =head1 AUTHORS | ||||||||||||
| 51 | |||||||||||||
| 52 | =over 4 | ||||||||||||
| 53 | |||||||||||||
| 54 | =item * | ||||||||||||
| 55 | |||||||||||||
| 56 | Kip Hampton <kip.hampton@tamarou.com> | ||||||||||||
| 57 | |||||||||||||
| 58 | =item * | ||||||||||||
| 59 | |||||||||||||
| 60 | Chris Prather <chris.prather@tamarou.com> | ||||||||||||
| 61 | |||||||||||||
| 62 | =back | ||||||||||||
| 63 | |||||||||||||
| 64 | =head1 COPYRIGHT AND LICENSE | ||||||||||||
| 65 | |||||||||||||
| 66 | This software is copyright (c) 2011 by Tamarou, LLC. | ||||||||||||
| 67 | |||||||||||||
| 68 | This is free software; you can redistribute it and/or modify it under | ||||||||||||
| 69 | the same terms as the Perl 5 programming language system itself. | ||||||||||||
| 70 | |||||||||||||
| 71 | =cut | ||||||||||||
| 72 | |||||||||||||