line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package KiokuDB::Backend::Serialize::Storable; |
4
|
20
|
|
|
20
|
|
12466
|
use Moose::Role; |
|
20
|
|
|
|
|
39
|
|
|
20
|
|
|
|
|
152
|
|
5
|
|
|
|
|
|
|
|
6
|
20
|
|
|
20
|
|
91555
|
use Storable qw(nfreeze thaw nstore_fd fd_retrieve); |
|
20
|
|
|
|
|
39015
|
|
|
20
|
|
|
|
|
1626
|
|
7
|
|
|
|
|
|
|
|
8
|
20
|
|
|
20
|
|
117
|
use namespace::clean -except => 'meta'; |
|
20
|
|
|
|
|
32
|
|
|
20
|
|
|
|
|
146
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with qw( |
11
|
|
|
|
|
|
|
KiokuDB::Backend::Serialize |
12
|
|
|
|
|
|
|
KiokuDB::Backend::Role::UnicodeSafe |
13
|
|
|
|
|
|
|
KiokuDB::Backend::Role::BinarySafe |
14
|
|
|
|
|
|
|
KiokuDB::Backend::TypeMap::Default::Storable |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub serialize { |
18
|
2013
|
|
|
2013
|
1
|
61211
|
my ( $self, $entry ) = @_; |
19
|
|
|
|
|
|
|
|
20
|
2013
|
|
|
|
|
4920
|
return nfreeze($entry); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub deserialize { |
24
|
8518
|
|
|
8518
|
1
|
86041
|
my ( $self, $blob ) = @_; |
25
|
|
|
|
|
|
|
|
26
|
8518
|
|
|
|
|
17617
|
return thaw($blob); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub serialize_to_stream { |
30
|
3
|
|
|
3
|
1
|
828
|
my ( $self, $fh, $entry ) = @_; |
31
|
3
|
|
|
|
|
8
|
nstore_fd($entry, $fh); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub deserialize_from_stream { |
35
|
4
|
|
|
4
|
1
|
372
|
my ( $self, $fh ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
4
|
100
|
|
|
|
13
|
if ( $fh->eof ) { |
38
|
1
|
|
|
|
|
6
|
return; |
39
|
|
|
|
|
|
|
} else { |
40
|
3
|
|
|
|
|
20
|
return fd_retrieve($fh); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__PACKAGE__ |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=pod |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
KiokuDB::Backend::Serialize::Storable - L<Storable> based serialization of |
53
|
|
|
|
|
|
|
L<KiokuDB::Entry> objects. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 SYNOPSIS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
package MyBackend; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
with qw(KiokuDB::Backend::Serialize::Storable; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 DESCRIPTION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This role provides L<Storable> based serialization of L<KiokuDB::Entry> objects |
64
|
|
|
|
|
|
|
for a backend, with streaming capabilities. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
L<KiokuDB::Backend::Serialize::Delegate> is preferred to using this directly. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 METHODS |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=over 4 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item serialize $entry |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Uses L<Storable/nstore> |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item deserialize $blob |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Uses L<Storable/thaw> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item serialize_to_stream $fh, $entry |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Uses L<Storable/nstore_fd>. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item deserialize_from_stream $fh |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Uses L<Storable/fd_retrieve>. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=back |