lib/AnyEvent/Memcached/Conn.pm

filter: Statementstmt 36.0% 18 / 50 Branchbran 0.0% 0 / 28 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 1 totaltotal 24.7% 22 / 89 SCAR 49.1
CC
16
Cov
22%
__ANON__
56.0
reader
42.0
__ANON__
30.0
CRAP 135.2
« blib/lib/AnyEvent/Memcached/Conn.pm ↑ Summary blib/lib/AnyEvent/Memcached/Buckets.pm »
1 package #hide
2 AnyEvent::Memcached::Conn;
3  
4 4 ▶use common::sense 2;m{
Subroutine BEGIN: called CC=1 SCAR=0.0
5 use strict;
6 use warnings;
7 }x;
8 4 ▶use base 'AnyEvent::Connection::Raw';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use AnyEvent::Memcached;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use AnyEvent::Connection::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 our $NL = "\015\012";
13 4 our $QRNL = qr<\015?\012>;
14 4 our $VERSION = $AnyEvent::Memcached::VERSION;
15  
16 sub reader {
17 0 ▶ my ($self,%args) = @_;
Subroutine reader: not called CC=6 SCAR=37.4
Pod undocumented
18 0 ▶ $args{cb} or return $self->event( error => "no cb for command at @{[ (caller)[1,2] ]}" );
Branch: 1 branch
BranchTrueFalseTotal
$args{"cb"} or return $self->event("error", "no cb for command at @{[(caller)[1, 2]];}") 0 0 0
19 0 ▶ $self->{h} or return $args{cb}->(undef,"Not connected");
Branch: 1 branch
BranchTrueFalseTotal
$self->{"h"} or return $args{"cb"}->(undef, "Not connected") 0 0 0
20 0 ▶ my $result = $args{res} || {};
Condition0%0/2
$args{'res'} || {}
l!l
00
MC/DC0%0/1
$args{'res'} || {}
$args{'res'}
Truth table0%0/2
A
A= $args{'res'}
Aresult
11
00
21 0 ▶ my $ar = ref $result eq 'ARRAY' ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
ref $result eq 'ARRAY' ? : 0 0 0
22 0 ▶ my $cut = exists $args{namespace} ? length $args{namespace} : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'namespace'} ? : 0 0 0
23 0 my $reader;$reader = sub {
24 0 ▶ shift;
Subroutine __ANON__: not called CC=7 SCAR=40.3
25 0 ▶ defined( local $_ = shift ) or return $args{cb}(undef,@_);
Branch: 1 branch
BranchTrueFalseTotal
defined(local $_ = shift()) or return $args{"cb"}->(undef, @_) 0 0 0
26 0 ▶ warn "<<$args{id} $_" if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
27 0 ▶ if ($_ eq "END") {
Branch: 4 branches
BranchTrueFalseTotal
if ($_ eq 'END') { } 0 0 0
elsif (substr($_, 0, 5) eq 'ERROR') { } 0 0 0
elsif (not length $_) { } 0 0 0
elsif (/^VALUE (\S+) (\d+) (\d+)(?:| (.+))$/u) { } 0 0 0
28 0 undef $reader;
29 0 $args{cb}( $result );
30 }
31 elsif (substr($_,0,5) eq 'ERROR') {
32 0 undef $reader;
33 0 $args{cb}( undef, $_ );
34 }
35 elsif (!length) {
36 0 warn "Skip empty line";
37 0 $self->{h}->unshift_read( line => $reader);
38 }
39 elsif( /^VALUE (\S+) (\d+) (\d+)(?:| (.+))$/ ) {
40 0 my ($key,$flags,$len,$cas) = ($1,$2,$3,$4);
41 #warn "have to read $1 $2 $3 $4";
42 $self->recv( $3+2 => cb => sub {
43 #shift;
44 0 ▶ my $data = shift;
Subroutine __ANON__: not called CC=5 SCAR=34.0
45 0 substr($data,$len) = ''; # trim out data outside length
46 #$data = substr($data,0,length($data)-2);
47 0 ▶ $key = substr($key, $cut) if substr($key, 0, $cut) eq $args{namespace};
Branch: 1 branch
BranchTrueFalseTotal
if substr($key, 0, $cut) eq $args{"namespace"} 0 0 0
48 0 ▶ warn "+ received data $key: $data" if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
49 0 ▶ my $v = {
Branch: 1 branch
BranchTrueFalseTotal
defined $cas ? : 0 0 0
50 data => $data,
51 flags => $flags,
52 defined $cas ? (cas => $cas) : (),
53 };
54 0 ▶ if ($ar) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ar) { } 0 0 0
55 0 push @$result, $key, $v;
56 } else {
57 0 $result->{$key} = $v;#{ data => $data, $cas ? (cas => $cas) : () };
58 }
59
60 0 $self->{h}->unshift_read( line => $reader);
61 0 });
62 }
63 else {
64 0 die "Wrong data received: ".dumper($_)."($!)";
65 #$args{cb}(undef,$_);
66 #$self->handle_errors($_);
67 }
68 0 };
69 0 $self->{h}->push_read( line => $reader );
70 }
71  
72  
73 4 1;
74  
75 4 1;
« blib/lib/AnyEvent/Memcached/Conn.pm ↑ Summary blib/lib/AnyEvent/Memcached/Buckets.pm »