line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Session::Store::File; |
2
|
4
|
|
|
4
|
|
1799
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
93
|
|
3
|
4
|
|
|
4
|
|
16
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
173
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.33'; |
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
2027
|
use Storable (); |
|
4
|
|
|
|
|
10283
|
|
|
4
|
|
|
|
|
93
|
|
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
21
|
use parent 'Plack::Session::Store'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
20
|
|
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
|
|
20
|
use Plack::Util::Accessor qw[ |
13
|
|
|
|
|
|
|
dir |
14
|
|
|
|
|
|
|
serializer |
15
|
|
|
|
|
|
|
deserializer |
16
|
4
|
|
|
4
|
|
173
|
]; |
|
4
|
|
|
|
|
22
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
3
|
|
|
3
|
1
|
2075
|
my ($class, %params) = @_; |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
0
|
|
|
11
|
$params{'dir'} ||= $ENV{TMPDIR} || '/tmp'; |
|
|
|
33
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
die "Storage directory (" . $params{'dir'} . ") is not writeable" |
24
|
3
|
50
|
|
|
|
35
|
unless -w $params{'dir'}; |
25
|
|
|
|
|
|
|
|
26
|
3
|
|
50
|
16
|
|
43
|
$params{'serializer'} ||= sub { Storable::lock_nstore( @_ ) }; |
|
16
|
|
|
|
|
69
|
|
27
|
3
|
|
50
|
12
|
|
23
|
$params{'deserializer'} ||= sub { Storable::lock_retrieve( @_ ) }; |
|
12
|
|
|
|
|
85
|
|
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
29
|
bless { %params } => $class; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub fetch { |
33
|
14
|
|
|
14
|
1
|
158640
|
my ($self, $session_id) = @_; |
34
|
|
|
|
|
|
|
|
35
|
14
|
|
|
|
|
34
|
my $file_path = $self->_get_session_file_path( $session_id ); |
36
|
14
|
100
|
|
|
|
283
|
return unless -f $file_path; |
37
|
|
|
|
|
|
|
|
38
|
12
|
|
|
|
|
48
|
$self->deserializer->( $file_path ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub store { |
42
|
16
|
|
|
16
|
1
|
92
|
my ($self, $session_id, $session) = @_; |
43
|
16
|
|
|
|
|
26
|
my $file_path = $self->_get_session_file_path( $session_id ); |
44
|
16
|
|
|
|
|
98
|
$self->serializer->( $session, $file_path ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub remove { |
48
|
2
|
|
|
2
|
1
|
12
|
my ($self, $session_id) = @_; |
49
|
2
|
|
|
|
|
5
|
unlink $self->_get_session_file_path( $session_id ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _get_session_file_path { |
53
|
32
|
|
|
32
|
|
54
|
my ($self, $session_id) = @_; |
54
|
32
|
|
|
|
|
68
|
$self->dir . '/' . $session_id; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |