| 1 | package Queue::Q::ClaimFIFO::Item; | ||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 5 | ▶ | use Sereal::Decoder; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 5 | ▶ | use Sereal::Encoder; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 5 | ▶ | use Digest::MD5 (); # much faster than sha1 and good enough | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 5 | ▶ | use Class::XSAccessor { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 5 | constructor => 'new', | |||||||||
| 10 | getters => [qw(item_data)], | ||||||||||
| 11 | 5 | }; | |||||||||
| 12 | |||||||||||
| 13 | 5 | ▶ | BEGIN { *data = \&item_data; } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 5 | our $SerealEncoder = Sereal::Encoder->new; | |||||||||
| 16 | 5 | our $SerealDecoder = Sereal::Decoder->new; | |||||||||
| 17 | 5 | our $MD5 = Digest::MD5->new; | |||||||||
| 18 | |||||||||||
| 19 | # for "friends" only | ||||||||||
| 20 | 0 | ▶ | sub _key { | ||||||||
|
Subroutine
_key: not called CC=2 SCAR=17.9
| |||||||||||
| 21 | 0 | my $self = shift; | |||||||||
| 22 | return $self->{_key} | ||||||||||
| 23 | 0 | ▶ | if defined $self->{_key}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | $MD5->add($self->_serialized_data); | |||||||||
| 25 | 0 | $MD5->add(rand(), time()); | |||||||||
| 26 | 0 | return( $self->{_key} = $MD5->digest ); | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | # for "friends" only | ||||||||||
| 30 | 0 | ▶ | sub _serialized_data { | ||||||||
|
Subroutine
_serialized_data: not called CC=2 SCAR=17.9
| |||||||||||
| 31 | 0 | my $self = shift; | |||||||||
| 32 | return $self->{_serialized_data} | ||||||||||
| 33 | 0 | ▶ | if defined $self->{_serialized_data}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | return( $self->{_serialized_data} = $self->_serialize_data($self->data) ); | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | # for "friends" only | ||||||||||
| 38 | 0 | ▶ | sub _serialize_data { | ||||||||
|
Subroutine
_serialize_data: not called CC=1 SCAR=6.9
| |||||||||||
| 39 | 0 | my $self = shift; | |||||||||
| 40 | 0 | return $SerealEncoder->encode($_[0]); | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | # for "friends" only | ||||||||||
| 44 | 0 | ▶ | sub _deserialize_data { | ||||||||
|
Subroutine
_deserialize_data: not called CC=2 SCAR=17.9
| |||||||||||
| 45 | 0 | my $self = shift; | |||||||||
| 46 | 0 | ▶ | return undef if not defined $_[0]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 0 | return $SerealDecoder->decode($_[0]); | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 5 | 1; | |||||||||
| 51 | __END__ | ||||||||||