line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Method::Cached::KeyRule::Serialize; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
766
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
47
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
46
|
|
5
|
2
|
|
|
2
|
|
8
|
use base qw/Method::Cached::KeyRule::Base/; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
681
|
|
6
|
2
|
|
|
2
|
|
956
|
use Digest::SHA; |
|
2
|
|
|
|
|
5016
|
|
|
2
|
|
|
|
|
85
|
|
7
|
2
|
|
|
2
|
|
1122
|
use JSON::XS; |
|
2
|
|
|
|
|
8603
|
|
|
2
|
|
|
|
|
104
|
|
8
|
2
|
|
|
2
|
|
1041
|
use Storable; |
|
2
|
|
|
|
|
5192
|
|
|
2
|
|
|
|
|
455
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
__PACKAGE__->export_rule(qw/SELF_CODED SERIALIZE/); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub SELF_CODED { |
13
|
|
|
|
|
|
|
my ($method_name, $args) = @_; |
14
|
|
|
|
|
|
|
our $ENCODER ||= JSON::XS->new->convert_blessed(1); |
15
|
|
|
|
|
|
|
*UNIVERSAL::TO_JSON = sub { Storable::nfreeze \@_ }; |
16
|
|
|
|
|
|
|
my $json = $ENCODER->encode($args->[0]); |
17
|
|
|
|
|
|
|
undef *UNIVERSAL::TO_JSON; |
18
|
|
|
|
|
|
|
$args->[0] = Digest::SHA::sha1_base64($json); |
19
|
|
|
|
|
|
|
return; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub SERIALIZE { |
23
|
|
|
|
|
|
|
my ($method_name, $args) = @_; |
24
|
|
|
|
|
|
|
local $^W = 0; |
25
|
|
|
|
|
|
|
our $ENCODER ||= JSON::XS->new->convert_blessed(1); |
26
|
|
|
|
|
|
|
*UNIVERSAL::TO_JSON = sub { Storable::nfreeze \@_ }; |
27
|
|
|
|
|
|
|
my $json = $ENCODER->encode($args); |
28
|
|
|
|
|
|
|
undef *UNIVERSAL::TO_JSON; |
29
|
|
|
|
|
|
|
$method_name . Digest::SHA::sha1_base64($json); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__END__ |