line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Session::Store::File; |
2
|
1
|
|
|
1
|
|
22217
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
5
|
use base qw/Class::Accessor::Fast/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
100
|
|
5
|
1
|
|
|
1
|
|
1200
|
use Storable; |
|
1
|
|
|
|
|
4322
|
|
|
1
|
|
|
|
|
441
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw/dir/); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
2
|
|
|
2
|
1
|
850
|
my $class = shift; |
11
|
2
|
50
|
|
|
|
13
|
my %args = ref($_[0]) ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
0
|
|
12
|
|
|
|
|
|
|
# check requried parameters |
13
|
2
|
|
|
|
|
6
|
for (qw/dir/) { |
14
|
2
|
50
|
|
|
|
12
|
Carp::croak "missing parameter $_" unless $args{$_}; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
# set default values |
17
|
2
|
|
|
|
|
29
|
bless {%args}, $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub select { |
21
|
2
|
|
|
2
|
1
|
13
|
my ($self, $key) = @_; |
22
|
2
|
100
|
|
|
|
12
|
if (open my $fh, '<', $self->_to_path($key)) { |
23
|
1
|
|
|
|
|
52
|
my $value = Storable::fd_retrieve($fh); |
24
|
1
|
|
|
|
|
72
|
close $fh; |
25
|
1
|
|
|
|
|
5
|
return $value; |
26
|
|
|
|
|
|
|
} |
27
|
1
|
|
|
|
|
71
|
undef; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub insert { |
31
|
1
|
|
|
1
|
1
|
13
|
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
|
|
7
|
my ($self, $key) = @_; |
46
|
3
|
|
|
|
|
8
|
$key =~ s/([^A-Za-pr-z0-9_])/sprintf("q%02x", ord $1)/eg; |
|
0
|
|
|
|
|
0
|
|
47
|
3
|
|
|
|
|
11
|
$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__ |