himik has asked for the wisdom of the Perl Monks concerning the following question:

Hello monkers !! :) I'm using Cache::Memcached::libmemcached;

Here is what i want to do

my $mem = Cache::Memcached::libmemcached->new( { servers => [ "$mcserv +er" ], compress_threshold => 10_000 } ); if ($mem) { my $tmp_value = $mem->get("tmpval"); } else { print "no conection to mem"; }
But $mem is awlays true .... How should i do it?

Replies are listed 'Best First'.
Re: How to check connection to Cache::Memcached::libmemcached;
by himik (Acolyte) on Nov 16, 2012 at 14:50 UTC

    I find way to do it, but .... I don't like it.

    my $mem = Cache::Memcached::libmemcached->new( { servers => [ "testser +ver" ], compress_threshold => 10_000 } ); if (!($mem->set("tmpval", 0, 60);)) { print "no conection to mem"; }

Re: How to check connection to Cache::Memcached::libmemcached;
by Anonymous Monk on Nov 16, 2012 at 13:59 UTC

    But $mem is awlays true .... How should i do it?

    That ought to work, what is the problem?

    I suppose you could check ->errstr , but if it returns an object when it should return undef, that is a bug

      when i do

      my $mem = Cache::Memcached::libmemcached->new( { servers => [ "12133 +21" ], compress_threshold => 10_000 } ); print $mem->errstr;
      The output is SUCCES. But the server is not valid one and I can not connect to it.