Memcached/Base.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 58 SCAR 24.8
CC
3
Cov
0%
BUILD
6.0
fetch_multi_hashref
6.0
_build_contained_cache
2.0
CRAP 12.0
1 package CHI::Driver::Memcached::Base;
2 $CHI::Driver::Memcached::Base::VERSION = '0.15';
3 use CHI;
4 use Carp;
5 use Class::Load;
6 use Moose;
7 use strict;
8 use warnings;
9  
10 has 'memd' => ( is => 'ro', init_arg => undef );
11 has 'memd_class' => ( is => 'ro' );
12 has 'memd_params' => ( is => 'ro' );
13  
14 extends 'CHI::Driver::Base::CacheContainer';
15  
16 # Unsupported methods
17 #
18 __PACKAGE__->declare_unsupported_methods(
19 qw(dump_as_hash get_keys get_namespaces is_empty clear purge));
20  
21 __PACKAGE__->meta->make_immutable();
22  
23 sub BUILD {
24 my ( $self, $params ) = @_;
25  
26 $self->{memd_params} ||= $self->non_common_constructor_params($params);
27 $self->{memd_params}->{namespace} ||= $self->{namespace} . ":";
28 $self->{memd} = $self->{_contained_cache} = $self->_build_contained_cache;
29 $self->{max_key_length} = 248 - length( $self->{namespace} )
30 if !defined( $self->{max_key_length} );
31 }
32  
33 sub _build_contained_cache {
34 my ($self) = @_;
35  
36 Class::Load::load_class( $self->memd_class );
37 return $self->memd_class->new( $self->memd_params );
38 }
39  
40 # Memcached supports fast multiple get
41 #
42  
43 sub fetch_multi_hashref {
44 my ( $self, $keys ) = @_;
45 croak "must specify keys" unless defined($keys);
46  
47 return $self->memd->get_multi(@$keys);
48 }
49  
50 1;