Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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 ?

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://978850]
Approved by moritz
[1nickt]: Morning monks, howzit?
[ambrus]: AAAAAAARGH!
[ambrus]: something must be wrong here
[ambrus]: oh I see. I'm stupid
[marto]: hi 1nickt!
[ambrus]: The file I'm reading is already filtered, which is why I found only one kind of entry.
[1nickt]: Sorry to upset you brother Ambrus ...
[1nickt]: Ah not me, good!

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2018-01-23 13:04 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (246 votes). Check out past polls.