line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Memcached::Client::Serializer::JSON; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
1294
|
$Memcached::Client::Serializer::JSON::VERSION = '2.01'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
#ABSTRACT: Implements Memcached Serializing using JSON |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
8
|
1
|
|
|
1
|
|
143
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
9
|
1
|
|
|
1
|
|
861
|
use Memcached::Client::Log qw{DEBUG LOG}; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
85
|
|
10
|
1
|
|
|
1
|
|
1457
|
use JSON qw{decode_json encode_json}; |
|
1
|
|
|
|
|
28255
|
|
|
1
|
|
|
|
|
6
|
|
11
|
1
|
|
|
1
|
|
193
|
use base qw{Memcached::Client::Serializer}; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
669
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
6
|
use constant F_JSON => 4; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
249
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub deserialize { |
16
|
5
|
|
|
5
|
1
|
12
|
my ($self, $data, $flags) = @_; |
17
|
|
|
|
|
|
|
|
18
|
5
|
100
|
|
|
|
14
|
return unless defined $data; |
19
|
|
|
|
|
|
|
|
20
|
4
|
|
100
|
|
|
15
|
$flags ||= 0; |
21
|
|
|
|
|
|
|
|
22
|
4
|
100
|
|
|
|
10
|
if ($flags & F_JSON) { |
23
|
1
|
|
|
|
|
2
|
$self->log ("Deserializing data") if DEBUG; |
24
|
1
|
|
|
|
|
148
|
$data = decode_json $data; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
23
|
return $data; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub serialize { |
31
|
5
|
|
|
5
|
1
|
10
|
my ($self, $data) = @_; |
32
|
|
|
|
|
|
|
|
33
|
5
|
100
|
|
|
|
35
|
return unless defined $data; |
34
|
|
|
|
|
|
|
|
35
|
4
|
|
|
|
|
6
|
my $flags = 0; |
36
|
|
|
|
|
|
|
|
37
|
4
|
100
|
|
|
|
10
|
if (ref $data) { |
38
|
1
|
|
|
|
|
3
|
$self->log ("Serializing data") if DEBUG; |
39
|
1
|
|
|
|
|
109
|
$data = encode_json $data; |
40
|
1
|
|
|
|
|
3
|
$flags |= F_JSON; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
4
|
|
|
|
|
22
|
return ($data, $flags); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub log { |
48
|
0
|
|
|
0
|
1
|
|
my ($self, $format, @args) = @_; |
49
|
0
|
|
|
|
|
|
LOG ($format, @args); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |