| 1 | package Cache::Memcached::libmemcached; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 18 | require bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 18 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 18 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 18 | ▶ | use Memcached::libmemcached 1.001701, qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | MEMCACHED_CALLBACK_PREFIX_KEY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | MEMCACHED_PREFIX_KEY_MAX_SIZE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 18 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 18 | ▶ | use base qw(Memcached::libmemcached); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 18 | ▶ | use Carp qw(croak carp); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 18 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 18 | ▶ | use Storable (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 18 | our $VERSION = '0.04001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 18 | ▶ | use constant HAVE_ZLIB => eval { require Compress::Zlib } && !$@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.4
Condition33%1/3
eval {
do {
require Compress::Zlib
}
} && !$@
MC/DC0%0/2
eval {
do {
require Compress::Zlib
}
} && !$@
eval {
do {
require Compress::Zlib
}
}
!$@
Truth table33%1/3
A && not(B)
A= eval {
do {
require Compress::Zlib
}
}B= !$@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 18 | ▶ | use constant F_STORABLE => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 18 | ▶ | use constant F_COMPRESS => 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 18 | ▶ | use constant OPTIMIZE => $ENV{PERL_LIBMEMCACHED_OPTIMIZE} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 18 | my %behavior; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 18 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=10 SCAR=38.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # Make sure to load bytes.pm if HAVE_ZLIB is enabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 18 | if (HAVE_ZLIB) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 18 | require bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # accessors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 18 | foreach my $field (qw(compress_enable compress_threshold compress_savings)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | eval sprintf(<<" EOSUB", $field, $field, $field, $field); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_compress_enable: not called CC=1 SCAR=4.9
Subroutine
get_compress_savings: not called CC=1 SCAR=4.9
Subroutine
get_compress_threshold: not called CC=1 SCAR=4.9
Subroutine
set_compress_enable: not called CC=1 SCAR=4.9
Subroutine
set_compress_savings: not called CC=1 SCAR=4.9
Subroutine
set_compress_threshold: not called CC=1 SCAR=4.9
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | sub set_%s { \$_[0]->{%s} = \$_[1] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | sub get_%s { \$_[0]->{%s} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | EOSUB | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 54 | ▶ | die if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # for Cache::Memcached compatibility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub enable_compress { shift->set_compress_enable(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enable_compress: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # XXX this should be done via subclasses | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 18 | if (OPTIMIZE) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # If the optimize flag is enabled, we do not support master key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # generation, cause we really care about the speed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | foreach my $method (qw(get set add replace prepend append cas delete)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | eval <<" EOSUB"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | sub $method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | shift->SUPER::memcached_${method}(\@_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | EOSUB | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | die if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # Regular case. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # Mental note. We only do this cause while we're faster than | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # Cache::Memcached::Fast, *even* when the above optimization isn't | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # toggled. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 18 | foreach my $method (qw(get set add replace prepend append cas delete)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | eval <<" EOSUB"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add: not called CC=3 SCAR=22.6
Subroutine
append: not called CC=3 SCAR=22.6
Subroutine
cas: not called CC=3 SCAR=22.6
Subroutine
delete: not called CC=3 SCAR=22.6
Subroutine
get: called CC=3 SCAR=22.6
Subroutine
prepend: not called CC=3 SCAR=22.6
Subroutine
replace: not called CC=3 SCAR=22.6
Subroutine
set: called CC=3 SCAR=22.6
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Branch: 16 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | sub $method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | my \$self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | my \$key = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | return \$self->SUPER::memcached_${method}(\$key, \@_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | unless ref \$key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | (my \$master_key, \$key) = @\$key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | if (\$master_key) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | \$self->SUPER::memcached_${method}_by_key(\$master_key, \$key, \@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | \$self->SUPER::memcached_${method}(\$key, \@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | EOSUB | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 144 | ▶ | die if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # Create get_*/is_*/set_* methods for some libmemcached behaviors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # We only do this for some because there are many and it's easy for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # the user to use memcached_behavior_set() etc directly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 18 | %behavior = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # non-boolean behaviors that are renamed (to be more descriptive) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | distribution_method => [ 0, 'distribution' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | hashing_algorithm => [ 0, 'hash' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # boolean behaviors that are not renamed: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | no_block => [ 1 ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | binary_protocol => [ 1 ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 18 | ▶ | while ( my ($method, $field_info) = each %behavior ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 72 | my $is_bool = $field_info->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 72 | ▶ | my $field = $field_info->[1] || $method; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$field_info->[1] || $method
MC/DC0%0/2
$field_info->[1] || $method
$field_info->[1]
$method
Truth table66%2/3
A || B
A= $field_info->[1]B= $method
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 72 | my $behavior = "Memcached::libmemcached::MEMCACHED_BEHAVIOR_\U$field"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | warn "$behavior doesn't exist\n" # sanity check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 18 | ▶ | unless do { no strict 'refs'; defined &$behavior }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 72 | my ($set, $get) = ("set_$method", "get_$method"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 72 | ▶ | $get = "is_$method" if $is_bool; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 72 | my $code = "sub $set { \$_[0]->memcached_behavior_set($behavior(), \$_[1]) }\n" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | . "sub $get { \$_[0]->memcached_behavior_get($behavior()) }"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | eval $code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_distribution_method: not called CC=1 SCAR=5.3
Subroutine
get_hashing_algorithm: not called CC=1 SCAR=5.3
Subroutine
is_binary_protocol: not called CC=1 SCAR=5.3
Subroutine
is_no_block: not called CC=1 SCAR=5.3
Subroutine
set_binary_protocol: not called CC=1 SCAR=5.3
Subroutine
set_distribution_method: not called CC=1 SCAR=5.3
Subroutine
set_hashing_algorithm: not called CC=1 SCAR=5.3
Subroutine
set_no_block: not called CC=1 SCAR=5.3
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 72 | ▶ | die "$@ while executing $code" if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | sub import | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 18 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 18 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 18 | Memcached::libmemcached->export_to_level(1, undef, @_) ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 16 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=15 SCAR=28.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 16 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 16 | ▶ | my %args = %{ shift || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 16 | my $self = $class->SUPER::new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 16 | ▶ | $self->trace_level(delete $args{debug}) if exists $args{debug}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | $self->namespace(delete $args{namespace}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 16 | ▶ | if exists $args{namespace}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 16 | $self->{compress_threshold} = delete $args{compress_threshold}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # Add support for Cache::Memcache::Fast's compress_ratio | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 16 | ▶ | $self->{compress_savingsS} = delete $args{compress_savings} || 0.20; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $args{'compress_savings'} || 0.2
MC/DC0%0/1
delete $args{'compress_savings'} || 0.2
delete $args{'compress_savings'}
Truth table50%1/2
A
A= delete $args{'compress_savings'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | $self->{compress_enable} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 16 | ▶ | exists $args{compress_enable} ? delete $args{compress_enable} : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # servers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 16 | ▶ | $args{servers} || croak "No servers specified"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 16 | $self->set_servers(delete $args{servers}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # old-style behavior options (see behavior_ block below) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 16 | foreach my $option (qw(no_block hashing_algorithm distribution_method binary_protocol)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 64 | ▶ | my $behavior = $behavior{$option}->[1] || $option; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$behavior{$option}[1] || $option
MC/DC0%0/2
$behavior{$option}[1] || $option
$behavior{$option}[1]
$option
Truth table66%2/3
A || B
A= $behavior{$option}[1]B= $option
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 64 | ▶ | $args{"behavior_$behavior"} = delete $args{$option} if exists $args{$option}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # allow any libmemcached behavior to be set via args to new() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 16 | for my $name (grep { /^behavior_/ } keys %args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | my $value = delete $args{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | my $behavior = "Memcached::libmemcached::MEMCACHED_\U$name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 18 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | ▶ | if (not defined &$behavior) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | carp "$name ($behavior) isn't available"; # sanity check | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | $self->memcached_behavior_set(&$behavior(), $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 16 | delete $args{readonly}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 16 | delete $args{no_rehash}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | carp "Unrecognised options: @{[ sort keys %args ]}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | if %args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # Set compression/serialization callbacks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 16 | $self->set_callback_coderefs( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # Closures so we have reference to $self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | $self->_mk_callbacks() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # behavior options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 16 | foreach my $option (qw(no_block hashing_algorithm distribution_method binary_protocol)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 64 | my $method = "set_$option"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 64 | ▶ | $self->$method( $args{$option} ) if exists $args{$option}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 16 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | ▶ | sub namespace { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
namespace: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | my $old_namespace = $self->memcached_callback_get(MEMCACHED_CALLBACK_PREFIX_KEY); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | my $namespace = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | ▶ | $self->memcached_callback_set(MEMCACHED_CALLBACK_PREFIX_KEY, $namespace) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | or carp $self->errstr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 2 | return $old_namespace; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | sub set_servers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 16 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_servers: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 16 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 16 | ▶ | my $servers = shift || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || []
MC/DC0%0/1
shift() || []
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # $self->{servers} = []; # for compatibility with Cache::Memcached | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # XXX should delete any existing servers from libmemcached | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 16 | foreach my $server (@$servers) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 16 | $self->server_add($server); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | sub server_add | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 16 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
server_add: called CC=8 SCAR=31.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 16 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 16 | ▶ | my $server = shift | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | or Carp::confess("server not specified"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 16 | my $weight = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 16 | ▶ | if (ref $server eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my @ary = @$server; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $server = shift @ary; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | $weight = shift @ary || 0 if @ary; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
shift @ary || 0
MC/DC0%0/1
shift @ary || 0
shift @ary
Truth table0%0/2
A
A= shift @ary
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | elsif (ref $server eq 'HASH') { # Cache::Memcached::Fast | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my $h = $server; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $server = $h->{address}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | $weight = $h->{weight} if exists $h->{weight}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # noreply is not supported | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 16 | ▶ | if ($server =~ /^([^:]+):([^:]+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 16 | my ($hostname, $port) = ($1, $2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 16 | $self->memcached_server_add_with_weight($hostname, $port, $weight); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | $self->memcached_server_add_unix_socket_with_weight( $server, $weight ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # for compatibility with Cache::Memcached | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # push @{$self->{servers}}, $server; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | sub _mk_callbacks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 16 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_callbacks: called CC=1 SCAR=1.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 16 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 16 | weaken($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | my $inflate = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my ($key, $flags) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | if ($flags & F_COMPRESS) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | if (! HAVE_ZLIB) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | croak("Data for $key is compressed, but we have no Compress::Zlib"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $_ = Compress::Zlib::memGunzip($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if ($flags & F_STORABLE) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $_ = Storable::thaw($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 16 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 16 | ▶ | my $deflate = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=23.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # Check if we have a complex structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 16 | ▶ | if (ref $_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $_ = Storable::nfreeze($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | $_[1] |= F_STORABLE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | # Check if we need compression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 16 | ▶ | if (HAVE_ZLIB && $self->{compress_enable} && $self->{compress_threshold}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"compress_enable"} and $self->{"compress_threshold"}
MC/DC50%1/2
$self->{"compress_enable"} and $self->{"compress_threshold"}
$self->{"compress_enable"}
$self->{"compress_threshold"}
Truth table66%2/3
A and B
A= $self->{"compress_enable"}B= $self->{"compress_threshold"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # Find the byte length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | my $length = bytes::length($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | ▶ | if ($length > $self->{compress_threshold}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $tmp = Compress::Zlib::memGzip($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if (bytes::length($tmp) / $length < 1 - $self->{compress_savingsS}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $_ = $tmp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $_[1] |= F_COMPRESS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 16 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 16 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 16 | return ($deflate, $inflate); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | sub incr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
incr: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | my $offset = shift || 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my $val = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | $self->memcached_increment($key, $offset, $val) || return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | return $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | sub decr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decr: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | my $offset = shift || 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $val = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | $self->memcached_decrement($key, $offset, $val) || return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | return $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | sub flush_all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flush_all: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $_[0]->memcached_flush(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 18 | *remove = \&delete; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | sub disconnect_all { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disconnect_all: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $_[0]->memcached_quit(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | sub server_versions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
server_versions: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my %versions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | # XXX not optimal, libmemcached knows these values without having to send a stats request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | $self->walk_stats('', sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | my ($key, $value, $hostport) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | $versions{$hostport} = $value if $key eq 'version'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | return \%versions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | sub stats | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stats: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | my ($stats_args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | # http://github.com/memcached/memcached/blob/master/doc/protocol.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | $stats_args = [ $stats_args ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$stats_args and not ref $stats_args
MC/DC0%0/2
$stats_args and not ref $stats_args
$stats_args
not ref $stats_args
Truth table0%0/3
A and not(B)
A= $stats_argsB= not ref $stats_args
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | if $stats_args and not ref $stats_args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | $stats_args ||= [ '' ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$stats_args ||= [""]
MC/DC0%0/1
$stats_args ||= [""]
$stats_args
Truth table0%0/2
A
A= $stats_args
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # stats keys that aren't matched by the prefix and suffix regexes below | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | # but which we want to accumulate in totals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my %total_misc_keys = map { ($_ => 1) } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | bytes evictions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | connection_structures curr_connections total_connections | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my %h; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | for my $type (@$stats_args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | my $code = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my ($key, $value, $hostport) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | # XXX - This is hardcoded in the callback cause r139 in perl-memcached | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # removed the magic of "misc" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | $type ||= 'misc'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$type ||= "misc"
MC/DC0%0/1
$type ||= "misc"
$type
Truth table0%0/2
A
A= $type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $h{hosts}{$hostport}{$type}{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | #warn "$_ ($key, $value, $hostport, $type)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # accumulate overall totals for some items | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | if ($type eq 'misc') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | if ($total_misc_keys{$key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$total_misc_keys{$key} or $key =~ /^(?:cmd|bytes)_/ or $key =~ /_(?:hits|misses|errors|yields|badval|items|read|written)$/
$total_misc_keys{$key} or $key =~ /^(?:cmd|bytes)_/
MC/DC0%0/3
$total_misc_keys{$key} or $key =~ /^(?:cmd|bytes)_/ or $key =~ /_(?:hits|misses|errors|yields|badval|items|read|written)$/
$total_misc_keys{$key}
$key =~ /^(?:cmd|bytes)_/
$key =~ /_(?:hits|misses|errors|yields|badval|items|read|written)$/
Truth table0%0/4
A or B or C
A= $total_misc_keys{$key}B= $key =~ /^(?:cmd|bytes)_/C= $key =~ /_(?:hits|misses|errors|yields|badval|items|read|written)$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | or $key =~ /^(?:cmd|bytes)_/ # prefixes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | or $key =~ /_(?:hits|misses|errors|yields|badval|items|read|written)$/ # suffixes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | $h{total}{$key} += $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | ▶ | elsif ($type eq 'malloc' or $type eq 'sizes') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$type eq "malloc" or $type eq "sizes"
MC/DC0%0/2
$type eq "malloc" or $type eq "sizes"
$type eq "malloc"
$type eq "sizes"
Truth table0%0/3
A or B
A= $type eq "malloc"B= $type eq "sizes"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $h{total}{"${type}_$key"} += $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | $self->walk_stats($type, $code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | return \%h; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | # for compatability with Cache::Memcached and Cache::Memcached::Managed 0.20: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | # https://rt.cpan.org/Ticket/Display.html?id=62512 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # sub sock_to_host { undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | # sub get_sock { undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | # sub forget_dead_hosts { undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 18 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||