line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoX::Session::Store::File; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
285772
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
81
|
|
4
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
66
|
|
5
|
2
|
|
|
2
|
|
12
|
use base 'MojoX::Session::Store'; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
2162
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
13427
|
use File::Spec; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
48
|
|
8
|
2
|
|
|
2
|
|
10
|
use Carp qw(croak); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1254
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->attr(dir => File::Spec->tmpdir); |
13
|
|
|
|
|
|
|
__PACKAGE__->attr(prefix => 'mojoxsess'); |
14
|
|
|
|
|
|
|
__PACKAGE__->attr(driver => 'MojoX::Session::Store::File::Driver::Storable'); |
15
|
|
|
|
|
|
|
__PACKAGE__->attr('_driver_instance'); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $_driver_instance; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
1
|
|
|
1
|
1
|
23
|
my $class = shift; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
21
|
my $self = $class->SUPER::new(@_); |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
43
|
my $driver_classname = $self->driver; |
25
|
1
|
50
|
|
|
|
20
|
unless($driver_classname =~ /^MojoX::Session::Store::File::Driver::/) { |
26
|
0
|
|
|
|
|
0
|
$driver_classname = "MojoX::Session::Store::File::Driver::$driver_classname"; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
71
|
my $driver_available = eval "require $driver_classname; 1"; |
30
|
1
|
50
|
|
|
|
7
|
unless($driver_available) { |
31
|
0
|
|
|
|
|
0
|
croak "Driver '$driver_classname' is not installed"; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
33
|
|
|
16
|
$_driver_instance ||= $driver_classname->new; |
35
|
1
|
|
|
|
|
29
|
$self->_driver_instance($_driver_instance); |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
18
|
$self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub create { |
41
|
1
|
|
|
1
|
1
|
2231
|
my $self = shift; |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
126
|
my($sid, $expires, $data) = @_; |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
5
|
my $file = $self->_get_file_name($sid); |
46
|
1
|
50
|
|
|
|
187
|
return if -e $file; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
31
|
return $self->_driver_instance->freeze($file, [$expires, $data]); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub update { |
52
|
1
|
|
|
1
|
1
|
1539
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
2
|
my($sid, $expires, $data) = @_; |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
5
|
my $file = $self->_get_file_name($sid); |
57
|
1
|
50
|
33
|
|
|
77
|
return if not -e $file or not -w _; |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
26
|
$self->_driver_instance->freeze($file, [$expires, $data]); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub load { |
63
|
3
|
|
|
3
|
1
|
2274
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
3
|
|
|
|
|
5
|
my $sid = shift; |
66
|
|
|
|
|
|
|
|
67
|
3
|
|
|
|
|
7
|
my $file = $self->_get_file_name($sid); |
68
|
3
|
100
|
66
|
|
|
263
|
return if not -e $file or not -r _; |
69
|
|
|
|
|
|
|
|
70
|
2
|
|
|
|
|
3
|
@{$self->_driver_instance->thaw($file)}; |
|
2
|
|
|
|
|
55
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub delete { |
74
|
1
|
|
|
1
|
1
|
3505
|
my $self = shift; |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
3
|
my $sid = shift; |
77
|
|
|
|
|
|
|
|
78
|
1
|
|
|
|
|
5
|
unlink $self->_get_file_name($sid); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _get_file_name { |
82
|
6
|
|
|
6
|
|
10
|
my $self = shift; |
83
|
|
|
|
|
|
|
|
84
|
6
|
|
|
|
|
7
|
my $sid = shift; |
85
|
|
|
|
|
|
|
|
86
|
6
|
|
|
|
|
149
|
File::Spec->catfile($self->dir, sprintf('%s_%s', $self->prefix, $sid)); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |