| 1 | package Cache::Ref::Role::API; | ||||||||||||||||||||||||||||
| 2 | 7 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 7 | $Cache::Ref::Role::API::AUTHORITY = 'cpan:NUFFIN'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | 7 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 7 | $Cache::Ref::Role::API::VERSION = '0.05'; # TRIAL | |||||||||||||||||||||||||||
| 7 | } | ||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 7 | requires qw( | |||||||||||||||||||||||||||
| 15 | get | ||||||||||||||||||||||||||||
| 16 | set | ||||||||||||||||||||||||||||
| 17 | remove | ||||||||||||||||||||||||||||
| 18 | clear | ||||||||||||||||||||||||||||
| 19 | hit | ||||||||||||||||||||||||||||
| 20 | expire | ||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 4 | ▶ | sub compute { | ||||||||||||||||||||||||||
|
Subroutine
compute: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | 4 | my ( $self, $key, $code ) = @_; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 4 | ▶ | croak "must specify key and code" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $key and defined $code
MC/DC0%0/2
defined $key and defined $code
defined $key
defined $code
Truth table33%1/3
A and B
A= defined $keyB= defined $code
| |||||||||||||||||||||||||||||
| 27 | unless defined($key) && defined($code); | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 4 | ▶ | if ( defined( my $cached = $self->get($key) ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 2 | return $cached; | |||||||||||||||||||||||||||
| 31 | } else { | ||||||||||||||||||||||||||||
| 32 | 2 | my $value = $code->(); | |||||||||||||||||||||||||||
| 33 | 2 | $self->set( $key => $value ); | |||||||||||||||||||||||||||
| 34 | 2 | return $value; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | # ex: set sw=4 et: | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 7 | __PACKAGE__; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | __END__ | ||||||||||||||||||||||||||||