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   2120 use strict;
  3         6  
  3         126  
3 3     3   18 use warnings;
  3         3  
  3         156  
4              
5             our $VERSION = '0.23';
6             our $AUTHORITY = 'cpan:STEVAN';
7              
8 3     3   20 use Scalar::Util qw[ blessed ];
  3         5  
  3         281  
9              
10 3     3   28 use parent 'Plack::Session::Store';
  3         5  
  3         25  
11              
12 3     3   164 use Plack::Util::Accessor qw[ cache ];
  3         26  
  3         13  
13              
14             sub new {
15 2     2 1 44 my ($class, %params) = @_;
16              
17 2 50 33     83 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         27 bless { %params } => $class;
24             }
25              
26             sub fetch {
27 12     12 1 49 my ($self, $session_id ) = @_;
28 12         25 $self->cache->get($session_id);
29             }
30              
31             sub store {
32 16     16 1 90 my ($self, $session_id, $session) = @_;
33 16         31 $self->cache->set($session_id => $session);
34             }
35              
36             sub remove {
37 2     2 1 13 my ($self, $session_id) = @_;
38 2         5 $self->cache->remove($session_id);
39             }
40              
41             1;
42              
43             __END__