line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Session::Store::File; |
2
|
1
|
|
|
1
|
|
26900
|
use strict; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
52
|
|
3
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
4
|
use base qw/Class::Accessor::Fast/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
97
|
|
5
|
1
|
|
|
1
|
|
505
|
use Storable; |
|
1
|
|
|
|
|
2608
|
|
|
1
|
|
|
|
|
310
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw/dir/); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
2
|
|
|
2
|
1
|
647
|
my $class = shift; |
11
|
2
|
50
|
|
|
|
11
|
my %args = ref($_[0]) ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
0
|
|
12
|
|
|
|
|
|
|
# check requried parameters |
13
|
2
|
|
|
|
|
4
|
for (qw/dir/) { |
14
|
2
|
50
|
|
|
|
8
|
Carp::croak "missing parameter $_" unless $args{$_}; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
# set default values |
17
|
2
|
|
|
|
|
18
|
bless {%args}, $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub select { |
21
|
2
|
|
|
2
|
1
|
13
|
my ($self, $key) = @_; |
22
|
2
|
100
|
|
|
|
11
|
if (open my $fh, '<', $self->_to_path($key)) { |
23
|
1
|
|
|
|
|
39
|
my $value = Storable::fd_retrieve($fh); |
24
|
1
|
|
|
|
|
42
|
close $fh; |
25
|
1
|
|
|
|
|
7
|
return $value; |
26
|
|
|
|
|
|
|
} |
27
|
1
|
|
|
|
|
35
|
undef; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub insert { |
31
|
1
|
|
|
1
|
1
|
35
|
my ($self, $key, $value) = @_; |
32
|
1
|
|
|
|
|
3
|
Storable::nstore $value, $self->_to_path($key); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub update { |
36
|
0
|
|
|
0
|
1
|
0
|
shift->insert(@_); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub delete { |
40
|
0
|
|
|
0
|
1
|
0
|
my ($self, $key) = @_; |
41
|
0
|
|
|
|
|
0
|
unlink $self->_to_path($key); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _to_path { |
45
|
3
|
|
|
3
|
|
5
|
my ($self, $key) = @_; |
46
|
3
|
|
|
|
|
8
|
$key =~ s/([^A-Za-pr-z0-9_])/sprintf("q%02x", ord $1)/eg; |
|
0
|
|
|
|
|
0
|
|
47
|
3
|
|
|
|
|
44
|
$self->dir . '/' . $key . '.dat'; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
0
|
0
|
|
sub cleanup { Carp::croak "This storage doesn't support cleanup" } |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
__END__ |