Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by PerlOnTheWay (Monk)
on Jun 28, 2012 at 07:49 UTC ( [id://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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-20 03:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found