File Coverage

blib/lib/Autocache/Strategy.pm
Criterion Covered Total %
statement 23 27 85.1
branch 2 2 100.0
condition n/a
subroutine 5 9 55.5
pod 4 5 80.0
total 34 43 79.0


line stmt bran cond sub pod time code
1             package Autocache::Strategy;
2              
3 5     5   3005 use Any::Moose;
  5         11  
  5         33  
4              
5 5     5   5941 use Autocache::Record;
  5         15  
  5         168  
6 5     5   32 use Autocache::Logger qw(get_logger);
  5         11  
  5         1543  
7              
8             #
9             # get REQ
10             #
11 0     0 1 0 sub get { return undef; }
12              
13             #
14             # set REQ REC
15             #
16 0     0 1 0 sub set { return $_[2]; }
17              
18             #
19             # delete KEY
20             #
21             # should we send the request all the way through here too?
22             #
23 0     0 1 0 sub delete { return undef; }
24              
25 0     0 1 0 sub clear { return undef; }
26              
27              
28             #
29             # create REQ
30             #
31             #
32             # create a cache record by invoking the function to be cached
33             #
34             # this generates a basic cache record, strategies built on top of this
35             # should feel free to add their own data elements to the cache record
36             #
37             sub create
38             {
39 67     67 0 110 my ($self,$req) = @_;
40 67         151 get_logger()->debug( "create" );
41 67         82 my $value;
42              
43 67 100       206 if( $req->context eq 'S' )
44             {
45 66         67 $value = $req->generator->( @{$req->args} );
  66         373  
46             }
47             else
48             {
49 1         2 my @value = $req->generator->( @{$req->args} );
  1         8  
50 1         8 $value = \@value;
51             }
52              
53 67         370 my $rec = Autocache::Record->new(
54             name => $req->name,
55             key => $req->key,
56             value => $value,
57             );
58              
59 67         179 return $rec;
60             }
61              
62 5     5   32 no Any::Moose;
  5         17  
  5         36  
63             __PACKAGE__->meta->make_immutable;
64              
65             1;
66              
67             __END__