line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Method::Cached; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
11081
|
use 5.008_001; |
|
5
|
|
|
|
|
22
|
|
|
5
|
|
|
|
|
430
|
|
4
|
5
|
|
|
5
|
|
33
|
use strict; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
549
|
|
5
|
5
|
|
|
5
|
|
108
|
use warnings; |
|
5
|
|
|
|
|
133
|
|
|
5
|
|
|
|
|
362
|
|
6
|
5
|
|
|
5
|
|
12601
|
use Sub::Attribute; |
|
5
|
|
|
|
|
31880
|
|
|
5
|
|
|
|
|
437
|
|
7
|
5
|
|
|
5
|
|
2890
|
use Method::Cached::Manager; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
62
|
|
8
|
5
|
|
|
5
|
|
4329
|
use Method::Cached::KeyRule; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
69
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.051'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub import { |
13
|
9
|
|
|
9
|
|
128
|
my $class = shift; |
14
|
9
|
|
|
|
|
31
|
my $caller = caller 0; |
15
|
9
|
100
|
|
|
|
54
|
return unless $class eq __PACKAGE__; |
16
|
5
|
50
|
|
|
|
69
|
return if $caller->isa(__PACKAGE__); |
17
|
|
|
|
|
|
|
{ |
18
|
5
|
|
|
5
|
|
422
|
no strict 'refs'; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
949
|
|
|
5
|
|
|
|
|
9
|
|
19
|
5
|
|
|
|
|
8
|
push @{$caller . '::ISA'}, __PACKAGE__; |
|
5
|
|
|
|
|
421
|
|
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub Cached :ATTR_SUB { |
24
|
24
|
|
|
24
|
0
|
4340
|
my ($package, $sym_ref, $code_ref, $attr, $args_code) = @_; |
25
|
24
|
|
|
|
|
57
|
my $name = $package . '::' . *{$sym_ref}{NAME}; |
|
24
|
|
|
|
|
243
|
|
26
|
24
|
100
|
|
4
|
|
2095
|
my @args = defined $args_code ? eval(<<__EVAL__) : (); ## no critic |
|
4
|
|
|
4
|
|
28
|
|
|
4
|
|
|
2
|
|
9
|
|
|
4
|
|
|
2
|
|
157
|
|
|
4
|
|
|
2
|
|
21
|
|
|
4
|
|
|
2
|
|
11
|
|
|
4
|
|
|
1
|
|
294
|
|
|
2
|
|
|
1
|
|
14
|
|
|
2
|
|
|
1
|
|
4
|
|
|
2
|
|
|
1
|
|
64
|
|
|
2
|
|
|
1
|
|
13
|
|
|
2
|
|
|
1
|
|
3
|
|
|
2
|
|
|
1
|
|
119
|
|
|
2
|
|
|
1
|
|
12
|
|
|
2
|
|
|
1
|
|
3
|
|
|
2
|
|
|
1
|
|
55
|
|
|
2
|
|
|
1
|
|
8
|
|
|
2
|
|
|
1
|
|
3
|
|
|
2
|
|
|
1
|
|
170
|
|
|
1
|
|
|
1
|
|
7
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
27
|
|
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
52
|
|
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
24
|
|
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
59
|
|
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
29
|
|
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
|
|
72
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22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
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
60
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
55
|
|
27
|
|
|
|
|
|
|
package $package; |
28
|
|
|
|
|
|
|
no strict 'subs'; |
29
|
|
|
|
|
|
|
no warnings; |
30
|
|
|
|
|
|
|
local \$SIG{__WARN__} = sub{ die }; |
31
|
|
|
|
|
|
|
($args_code) |
32
|
|
|
|
|
|
|
__EVAL__ |
33
|
24
|
|
|
|
|
119
|
Method::Cached::Manager->set_method_setting($name, $attr, @args); |
34
|
|
|
|
|
|
|
{ |
35
|
5
|
|
|
5
|
|
29
|
no strict 'refs'; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
161
|
|
|
24
|
|
|
|
|
40
|
|
36
|
5
|
|
|
5
|
|
25
|
no warnings 'redefine'; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
821
|
|
37
|
24
|
|
|
|
|
5377
|
*{$name} = sub { |
38
|
102
|
|
|
102
|
|
18012379
|
unshift @_, $name, $code_ref, wantarray; |
39
|
102
|
|
|
|
|
385
|
goto &Method::Cached::LocalWrapper::_wrapper; |
40
|
24
|
|
|
|
|
86
|
}; |
41
|
|
|
|
|
|
|
} |
42
|
5
|
|
|
5
|
|
33
|
} |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
42
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
package # |
46
|
|
|
|
|
|
|
Method::Cached::LocalWrapper; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _wrapper { |
49
|
102
|
|
|
102
|
|
999
|
my ($name, $code_ref, $warray) = splice @_, 0, 3; |
50
|
102
|
|
|
|
|
555
|
my $method = Method::Cached::Manager->get_method_setting($name); |
51
|
102
|
|
|
|
|
471
|
my $domain = Method::Cached::Manager->get_domain_setting($method->{domain}); |
52
|
102
|
|
66
|
|
|
379
|
my $rule = $method->{key_rule} || $domain->{key_rule}; |
53
|
102
|
|
|
|
|
513
|
my $key = Method::Cached::KeyRule::regularize($rule, $name, [ @_ ]); |
54
|
102
|
100
|
|
|
|
395
|
my $key_f = $key . ($warray ? ':l' : ':s'); |
55
|
102
|
|
|
|
|
449
|
my $cache = Method::Cached::Manager->get_instance($domain); |
56
|
102
|
|
|
|
|
285571
|
my $ret = $cache->get($key_f); |
57
|
102
|
100
|
|
|
|
10306
|
unless ($ret) { |
58
|
71
|
100
|
|
|
|
429
|
$ret = [ $warray ? $code_ref->(@_) : scalar $code_ref->(@_) ]; |
59
|
71
|
|
100
|
|
|
4237
|
$cache->set($key_f, $ret, $method->{expires} || 0); |
60
|
|
|
|
|
|
|
} |
61
|
102
|
100
|
|
|
|
11396
|
return $warray ? @{ $ret } : $ret->[0]; |
|
15
|
|
|
|
|
100
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |