| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Queue::Q::ClaimFIFO::Item; | 
| 2 | 5 |  |  | 5 |  | 25 | use strict; | 
|  | 5 |  |  |  |  | 10 |  | 
|  | 5 |  |  |  |  | 125 |  | 
| 3 | 5 |  |  | 5 |  | 24 | use warnings; | 
|  | 5 |  |  |  |  | 9 |  | 
|  | 5 |  |  |  |  | 120 |  | 
| 4 | 5 |  |  | 5 |  | 24 | use Sereal::Decoder; | 
|  | 5 |  |  |  |  | 10 |  | 
|  | 5 |  |  |  |  | 186 |  | 
| 5 | 5 |  |  | 5 |  | 25 | use Sereal::Encoder; | 
|  | 5 |  |  |  |  | 15 |  | 
|  | 5 |  |  |  |  | 151 |  | 
| 6 | 5 |  |  | 5 |  | 25 | use Digest::MD5 (); # much faster than sha1 and good enough | 
|  | 5 |  |  |  |  | 16 |  | 
|  | 5 |  |  |  |  | 152 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | use Class::XSAccessor { | 
| 9 | 5 |  |  |  |  | 55 | constructor => 'new', | 
| 10 |  |  |  |  |  |  | getters => [qw(item_data)], | 
| 11 | 5 |  |  | 5 |  | 2991 | }; | 
|  | 5 |  |  |  |  | 10259 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 | 5 |  |  | 5 |  | 3274 | BEGIN { *data = \&item_data; } | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | our $SerealEncoder = Sereal::Encoder->new; | 
| 16 |  |  |  |  |  |  | our $SerealDecoder = Sereal::Decoder->new; | 
| 17 |  |  |  |  |  |  | our $MD5 = Digest::MD5->new; | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | # for "friends" only | 
| 20 |  |  |  |  |  |  | sub _key { | 
| 21 | 0 |  |  | 0 |  |  | my $self = shift; | 
| 22 |  |  |  |  |  |  | return $self->{_key} | 
| 23 | 0 | 0 |  |  |  |  | if defined $self->{_key}; | 
| 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 |  |  |  |  |  |  | sub _serialized_data { | 
| 31 | 0 |  |  | 0 |  |  | my $self = shift; | 
| 32 |  |  |  |  |  |  | return $self->{_serialized_data} | 
| 33 | 0 | 0 |  |  |  |  | if defined $self->{_serialized_data}; | 
| 34 | 0 |  |  |  |  |  | return( $self->{_serialized_data} = $self->_serialize_data($self->data) ); | 
| 35 |  |  |  |  |  |  | } | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | # for "friends" only | 
| 38 |  |  |  |  |  |  | sub _serialize_data { | 
| 39 | 0 |  |  | 0 |  |  | my $self = shift; | 
| 40 | 0 |  |  |  |  |  | return $SerealEncoder->encode($_[0]); | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | # for "friends" only | 
| 44 |  |  |  |  |  |  | sub _deserialize_data { | 
| 45 | 0 |  |  | 0 |  |  | my $self = shift; | 
| 46 | 0 | 0 |  |  |  |  | return undef if not defined $_[0]; | 
| 47 | 0 |  |  |  |  |  | return $SerealDecoder->decode($_[0]); | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | 1; | 
| 51 |  |  |  |  |  |  | __END__ |