line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MLDBM::Easy; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
52488
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
363
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
@ISA = 'MLDBM'; |
6
|
|
|
|
|
|
|
$VERSION = '0.01'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my %cache; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub import { |
11
|
1
|
|
|
1
|
|
11
|
my $pkg = shift; |
12
|
1
|
|
|
|
|
441
|
require MLDBM; |
13
|
0
|
|
|
|
|
|
MLDBM->import(@_); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub FETCH { |
18
|
0
|
|
|
0
|
|
|
my ($self, $key) = @_; |
19
|
0
|
|
|
|
|
|
my $ret = $self->{SR}->deserialize($self->{DB}->FETCH($key)); |
20
|
0
|
0
|
|
|
|
|
return $cache{$self,$key} if $cache{$self,$key}; |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
if (ref($ret) eq "HASH") { |
23
|
0
|
|
|
|
|
|
tie my(%h), 'MLDBM::Easy::Hash', $self, $key, $ret; |
24
|
0
|
|
|
|
|
|
return $cache{$self,$key} = \%h; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
if (ref($ret) eq "ARRAY") { |
28
|
0
|
|
|
|
|
|
tie my(@a), 'MLDBM::Easy::Array', $self, $key, $ret; |
29
|
0
|
|
|
|
|
|
return $cache{$self,$key} = \@a; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if (ref($ret) eq "SCALAR") { |
33
|
0
|
|
|
|
|
|
tie my($s), 'MLDBM::Easy::Scalar', $self, $key, $ret; |
34
|
0
|
|
|
|
|
|
return $cache{$self,$key} = \$s; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub STORE { |
40
|
0
|
|
|
0
|
|
|
my ($self, $key, $value) = @_; |
41
|
0
|
|
|
|
|
|
$value = $self->{SR}->serialize($cache{$self,$key}); |
42
|
0
|
|
|
|
|
|
$self->{DB}->STORE($key, $value); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
package MLDBM::Easy::Hash; |
47
|
1
|
|
|
1
|
|
1236
|
use Tie::Hash; |
|
1
|
|
|
|
|
1323
|
|
|
1
|
|
|
|
|
146
|
|
48
|
|
|
|
|
|
|
@ISA = 'Tie::StdHash'; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub TIEHASH { |
51
|
0
|
|
|
0
|
|
|
my ($class, $mldbm, $key, $href) = @_; |
52
|
0
|
|
|
|
|
|
my $self = bless $href, $class; |
53
|
0
|
|
|
|
|
|
$cache{$self} = [$mldbm, $key]; |
54
|
0
|
|
|
|
|
|
return $self; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub STORE { |
58
|
0
|
|
|
0
|
|
|
my ($self, $key, $value) = @_; |
59
|
0
|
|
|
|
|
|
$self->{$key} = $value; |
60
|
0
|
|
|
|
|
|
$cache{$self}->[0]->STORE($cache{$self}->[1], $self); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
package MLDBM::Easy::Array; |
65
|
1
|
|
|
1
|
|
891
|
use Tie::Array; |
|
1
|
|
|
|
|
1449
|
|
|
1
|
|
|
|
|
141
|
|
66
|
|
|
|
|
|
|
@ISA = 'Tie::StdArray'; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub TIEARRAY { |
69
|
0
|
|
|
0
|
|
|
my ($class, $mldbm, $key, $href) = @_; |
70
|
0
|
|
|
|
|
|
my $self = bless $href, $class; |
71
|
0
|
|
|
|
|
|
$cache{$self} = [$mldbm, $key]; |
72
|
0
|
|
|
|
|
|
return $self; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub STORE { |
76
|
0
|
|
|
0
|
|
|
my ($self, $idx, $value) = @_; |
77
|
0
|
|
|
|
|
|
$self->[$idx] = $value; |
78
|
0
|
|
|
|
|
|
$cache{$self}->[0]->STORE($cache{$self}->[1], $self); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
package MLDBM::Easy::Scalar; |
83
|
1
|
|
|
1
|
|
842
|
use Tie::Scalar; |
|
1
|
|
|
|
|
810
|
|
|
1
|
|
|
|
|
143
|
|
84
|
|
|
|
|
|
|
@ISA = 'Tie::StdScalar'; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub TIESCALAR { |
87
|
0
|
|
|
0
|
|
|
my ($class, $mldbm, $key, $sref) = @_; |
88
|
0
|
|
|
|
|
|
my $self = bless $sref, $class; |
89
|
0
|
|
|
|
|
|
$cache{$self} = [$mldbm, $key]; |
90
|
0
|
|
|
|
|
|
return $self; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub STORE { |
94
|
0
|
|
|
0
|
|
|
my ($self, $value) = @_; |
95
|
0
|
|
|
|
|
|
$$self = $value; |
96
|
0
|
|
|
|
|
|
$cache{$self}->[0]->STORE($cache{$self}->[1], $self); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |