line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Method::Cached::KeyRule::Serialize; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
11762
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
86
|
|
4
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
69
|
|
5
|
2
|
|
|
2
|
|
13
|
use base qw/Method::Cached::KeyRule::Base/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
2791
|
|
6
|
2
|
|
|
2
|
|
518211
|
use Digest::SHA; |
|
2
|
|
|
|
|
13279
|
|
|
2
|
|
|
|
|
221
|
|
7
|
2
|
|
|
2
|
|
3754
|
use JSON::XS; |
|
2
|
|
|
|
|
39544
|
|
|
2
|
|
|
|
|
1456
|
|
8
|
2
|
|
|
2
|
|
2954
|
use Storable; |
|
2
|
|
|
|
|
18942
|
|
|
2
|
|
|
|
|
2303
|
|
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
|
|
|
|
|
|
|
local *UNIVERSAL::TO_JSON = sub { Storable::nfreeze \@_ }; |
16
|
|
|
|
|
|
|
my $json = $ENCODER->encode($args->[0]); |
17
|
|
|
|
|
|
|
$args->[0] = Digest::SHA::sha1_base64($json); |
18
|
|
|
|
|
|
|
return; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub SERIALIZE { |
22
|
|
|
|
|
|
|
my ($method_name, $args) = @_; |
23
|
|
|
|
|
|
|
our $ENCODER ||= JSON::XS->new->convert_blessed(1); |
24
|
|
|
|
|
|
|
local $^W = 0; |
25
|
|
|
|
|
|
|
local *UNIVERSAL::TO_JSON = sub { Storable::nfreeze \@_ }; |
26
|
|
|
|
|
|
|
my $json = $ENCODER->encode($args); |
27
|
|
|
|
|
|
|
$method_name . Digest::SHA::sha1_base64($json); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
__END__ |