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   1535 use strict;
  3         5  
  3         102  
3 3     3   13 use warnings;
  3         3  
  3         144  
4              
5             our $VERSION = '0.30';
6             our $AUTHORITY = 'cpan:STEVAN';
7              
8 3     3   13 use Scalar::Util qw[ blessed ];
  3         5  
  3         216  
9              
10 3     3   26 use parent 'Plack::Session::Store';
  3         3  
  3         21  
11              
12 3     3   136 use Plack::Util::Accessor qw[ cache ];
  3         17  
  3         13  
13              
14             sub new {
15 2     2 1 42 my ($class, %params) = @_;
16              
17 2 50 33     67 die('cache require get, set and remove method.')
      33        
      33        
18             unless blessed $params{cache}
19             && $params{cache}->can('get')
20             && $params{cache}->can('set')
21             && $params{cache}->can('remove');
22              
23 2         24 bless { %params } => $class;
24             }
25              
26             sub fetch {
27 12     12 1 50 my ($self, $session_id ) = @_;
28 12         26 $self->cache->get($session_id);
29             }
30              
31             sub store {
32 16     16 1 94 my ($self, $session_id, $session) = @_;
33 16         27 $self->cache->set($session_id => $session);
34             }
35              
36             sub remove {
37 2     2 1 12 my ($self, $session_id) = @_;
38 2         5 $self->cache->remove($session_id);
39             }
40              
41             1;
42              
43             __END__