Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Can Cache::Memcached::Fast distinguish timeout or not existing?

by PerlOnTheWay (Scribe)
on Jun 28, 2012 at 07:49 UTC ( #978850=perlquestion: print w/ replies, xml ) Need Help??
PerlOnTheWay has asked for the wisdom of the Perl Monks concerning the following question:

"get" $memd−>get($key); Retrieve the value for a $key. $key should be a scalar. Return: value associated with the $key, or nothing.

If a key doesn't exist, I can nothing.

If it times out, I can nothing either.

How can I distinguish these two different cases after I get nothing from Cache::Memcached::Fast::get ?

Comment on Can Cache::Memcached::Fast distinguish timeout or not existing?
Download Code
Re: Can Cache::Memcached::Fast distinguish timeout or not existing?
by Khen1950fx (Canon) on Jun 28, 2012 at 16:39 UTC
    Something similar to this?
    #!/usr/bin/perl use strict; use warnings; use Cache::Memcached::Fast; use Cache::Memcached; use constant count => 2; my %params; foreach my $h (@{$params{servers}}) { $h->{noreply} = 1 if ref($h) eq 'HASH'; } my $another = new Cache::Memcached::Fast(\%params); my @keys = map { "noreply-$_" } (1..count); $another->set_multi(map { [$_, $_] } @keys); my $res = $another->get_multi(@keys); my $count = 0; foreach my $k (@keys) { if ($res->{$k} and $res->{$k} eq $k) { print $res; } else { print "Nothing\n"; } }

      Something similar to this?

      Hmm, lets try that , question: Can ... distinguish timeout or not existing ?

      Answer: Something similar to this?

      Hmm, the question something similar? doesn't answer Can .. yes or no?

      Also, the code doesn't answer the question either

      Too bad

        You didn't answer the question either. Too bad. Post your solution, please.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://978850]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2014-09-21 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (176 votes), past polls