line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Session::Store::DBM; |
2
|
2
|
|
|
2
|
|
27290
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
53
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
51
|
|
4
|
2
|
|
|
2
|
|
9
|
use base qw/Class::Accessor::Fast/; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
205
|
|
5
|
2
|
|
|
2
|
|
11
|
use Fcntl; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
492
|
|
6
|
2
|
|
|
2
|
|
1154
|
use Storable; |
|
2
|
|
|
|
|
5775
|
|
|
2
|
|
|
|
|
96
|
|
7
|
2
|
|
|
2
|
|
15
|
use Module::Runtime (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
677
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw/file dbm_class/); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
4
|
|
|
4
|
1
|
702
|
my $class = shift; |
13
|
4
|
50
|
|
|
|
19
|
my %args = ref($_[0]) ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
0
|
|
14
|
|
|
|
|
|
|
# check required parameters |
15
|
4
|
|
|
|
|
8
|
for (qw/file/) { |
16
|
4
|
50
|
|
|
|
15
|
Carp::croak "missing parameter $_" unless $args{$_}; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
# set default values |
19
|
4
|
|
100
|
|
|
19
|
$args{dbm_class} ||= 'SDBM_File'; |
20
|
4
|
|
|
|
|
35
|
bless {%args}, $class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub dbm { |
24
|
6
|
|
|
6
|
0
|
190
|
my $self = shift; |
25
|
6
|
|
66
|
|
|
110
|
$self->{dbm} ||= do { |
26
|
4
|
|
|
|
|
7
|
my %hash; |
27
|
4
|
50
|
|
|
|
65
|
Module::Runtime::require_module($self->dbm_class) or die $@; |
28
|
4
|
50
|
|
|
|
4552
|
tie %hash, $self->dbm_class, $self->file, O_CREAT | O_RDWR, oct("600") or die "Cannot open dbm file for session: $self->{dbm_class}, $self->{file}"; |
29
|
4
|
|
|
|
|
398
|
\%hash; |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub select { |
34
|
4
|
|
|
4
|
1
|
29
|
my ( $self, $key ) = @_; |
35
|
4
|
|
|
|
|
10
|
Storable::thaw $self->dbm->{$key}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub insert { |
39
|
2
|
|
|
2
|
1
|
77
|
my ( $self, $key, $value ) = @_; |
40
|
2
|
|
|
|
|
9
|
$self->dbm->{$key} = Storable::freeze $value; |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
0
|
1
|
|
sub update { shift->insert(@_) } |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub delete { |
45
|
0
|
|
|
0
|
1
|
|
my ( $self, $key ) = @_; |
46
|
0
|
|
|
|
|
|
delete $self->dbm->{$key}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
0
|
0
|
|
sub cleanup { Carp::croak "This storage doesn't support cleanup" } |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
__END__ |