We discovered this as well a few months ago... I don't think we found a workaround :(
Maybe someone else has? On Fri, 12 Mar 2010, Jonathan Swartz wrote: > We make liberal use of the namespace option to > Cache::Memcached::libmemcached, creating one object for each of our > dozens of namespaces. > > However I recently discovered that it will create new socket > connections for each object. i.e.: > > #!/usr/bin/perl -w > use Cache::Memcached; > use strict; > > my ( $class, $iter ) = @ARGV or die "usage: $0 class iter"; > eval "require $class"; > > my @memd; > for my $i ( 0 .. $iter ) { > $memd[$i] = $class->new( { servers => ["localhost:11211"] } ); > $memd[$i]->get('foo'); > } > > my $memd = new Cache::Memcached { servers => ["localhost:11211"] }; > my $stats = $memd->stats; > print "curr_connections: " . $stats->{total}->{curr_connections} . > "\n"; > > swartz> ./sockets.pl Cache::Memcached 50 > curr_connections: 10 > swartz> ./sockets.pl Cache::Memcached::Fast 50 > curr_connections: 61 > swartz> ./sockets.pl Cache::Memcached::libmemcached 50 > curr_connections: 61 > > I don't know why curr_connections starts at 10. In any case, > curr_connections will not grow with the number of Cache::Memcached > objects created, but will grow with the number of > Cache::Memcached::Fast or Cache::Memcached::libmemcached objects > created. > > I was a little surprised that libmemcached, at least, didn't have this > feature. Just wondering if I'm doing something wrong. > > If I want to keep using libmemcached, I guess I will have to create > just one option and override its namespace each time I use it. > > Jon >