line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hub::Knots::Nest; |
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
3
|
1
|
|
|
1
|
|
5
|
use Hub qw/:lib/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
our $VERSION = '4.00043'; |
5
|
|
|
|
|
|
|
our @EXPORT = qw//; |
6
|
|
|
|
|
|
|
our @EXPORT_OK = qw//; |
7
|
|
|
|
|
|
|
push our @ISA, qw(Tie::StdHash); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Cache |
10
|
|
|
|
|
|
|
our %CACHE = (); |
11
|
0
|
|
|
0
|
|
|
sub _fetch_cached { $CACHE{$_[0]} } |
12
|
|
|
|
|
|
|
sub _store_cached { |
13
|
0
|
0
|
|
0
|
|
|
if(defined $_[1]) { |
14
|
0
|
0
|
|
|
|
|
_delete_cached($_[0]) if ref($CACHE{$_[0]}); |
15
|
0
|
|
|
|
|
|
$CACHE{$_[0]} = $_[1]; |
16
|
|
|
|
|
|
|
} else { |
17
|
0
|
|
|
|
|
|
$_[1]; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
0
|
0
|
|
0
|
|
|
sub _delete_cached { map {/^$_[0]/ and delete $CACHE{$_}} keys %CACHE; } |
|
0
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Access |
23
|
0
|
0
|
|
0
|
|
|
sub FETCH { _fetch_cached($_[1]) || _store_cached($_[1], Hub::getv(@_)); } |
24
|
0
|
|
|
0
|
|
|
sub STORE { Hub::setv(@_); _store_cached($_[1], $_[2]); } |
|
0
|
|
|
|
|
|
|
25
|
0
|
|
|
0
|
|
|
sub DELETE { Hub::delete(@_); _delete_cached($_[1]); } |
|
0
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=pod:summary Nested data structure |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=pod:synopsis |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=pod:description |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |