File Coverage

blib/lib/Plack/Session/Store/Cache.pm
Criterion Covered Total %
statement 24 24 100.0
branch 1 2 50.0
condition 3 9 33.3
subroutine 9 9 100.0
pod 4 4 100.0
total 41 48 85.4


line stmt bran cond sub pod time code
1             package Plack::Session::Store::Cache;
2 3     3   1489 use strict;
  3         5  
  3         72  
3 3     3   14 use warnings;
  3         4  
  3         119  
4              
5             our $VERSION = '0.33';
6             our $AUTHORITY = 'cpan:STEVAN';
7              
8 3     3   15 use Scalar::Util qw[ blessed ];
  3         5  
  3         152  
9              
10 3     3   15 use parent 'Plack::Session::Store';
  3         5  
  3         20  
11              
12 3     3   129 use Plack::Util::Accessor qw[ cache ];
  3         5  
  3         14  
13              
14             sub new {
15 2     2 1 178 my ($class, %params) = @_;
16              
17             die('cache require get, set and remove method.')
18             unless blessed $params{cache}
19             && $params{cache}->can('get')
20             && $params{cache}->can('set')
21 2 50 33     43 && $params{cache}->can('remove');
      33        
      33        
22              
23 2         20 bless { %params } => $class;
24             }
25              
26             sub fetch {
27 12     12 1 82 my ($self, $session_id ) = @_;
28 12         25 $self->cache->get($session_id);
29             }
30              
31             sub store {
32 16     16 1 114 my ($self, $session_id, $session) = @_;
33 16         84 $self->cache->set($session_id => $session);
34             }
35              
36             sub remove {
37 2     2 1 14 my ($self, $session_id) = @_;
38 2         11 $self->cache->remove($session_id);
39             }
40              
41             1;
42              
43             __END__