Perl Cache::Memcached not connecting

Cahill, Earl ecahill at corp.untd.com
Thu Nov 9 06:57:36 UTC 2006


I think you just need to make servers an array ref, like so

my $mcd = new Cache::Memcached {'servers' => ["127.0.0.1:11211"]};

I think that's kind of a bug, but maybe not.  I think it should at least
die on the instantiation with something like 'servers needs to be an
array ref', but I would say, heck, just change it to an array ref on the
fly

Seems like something like

$self->{'servers'} = [$self->{'servers'}]
unless(UNIVERSAL::isa($self->{'servers'}, 'ARRAY'));

Right after 

    $self->{'servers'} = $list || [];

In set_servers would do the trick.

I have made your same mistake in the past.

Enjoy!

Earl

-----Original Message-----
From: memcached-bounces at lists.danga.com
[mailto:memcached-bounces at lists.danga.com] On Behalf Of Adam Dixon
Sent: Wednesday, November 08, 2006 11:42 PM
To: memcached at lists.danga.com
Subject: Perl Cache::Memcached not connecting

Hi,
First time playing about with memcached, seems pretty straight
forward, start it up, and start 'set'ing objects into the cache; My
example perl script however doesnt work, I cannot seem to get it to
actually connect (when starting memcached with -vv).
Ive tried this on 3 systems 2 CentOS4 perl 5.8.5 and a FreeBSD 6.1
with perl 5.8.8 both seem to be acting the same.
I installed libevent and memcached from the source downloads and
Cache::Memcached from CPAN

memcache source files 'make test' looks ok to me, 2 subtests skipped
but that seems normal from my googling.
#----------------------
#!/usr/bin/perl
use Cache::Memcached;
use Data::Dumper;
use strict;

my ($obj, $username);
my $mcd = new Cache::Memcached {'servers' => "127.0.0.1:11211"};

print $mcd->set("my_key", "Some value");
Dumper($mcd->get("my_key"));
exit;
#----------------------

This always prints 0, as in, not actually set properly. I dont get any
output when memcached is running under -vv (apart from when it starts
up).

Anyone know what I can try to get this going properly?

Regards
Adam


More information about the memcached mailing list