Skip Menu |

This queue is for tickets about the Cache-Memcached CPAN distribution.

Report information
The Basics
Id: 43684
Status: resolved
Priority: 0/
Queue: Cache-Memcached

People
Owner: Nobody in particular
Requestors: mark [...] aufflick.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.24
Fixed in: (no value)



Subject: Added method to obtain most recent result message (NOT_FOUND etc).
I have attached a patch which allows obtaining the most recent protocol result (eg. NOT_FOUND etc) for non-get commands. This is useful if you eg. want to distinguish between NOT_FOUND and some other error (eg. lost connection, protocol error etc.)
Subject: Memcached.patch
--- Cache-Memcached-1.24/lib/Cache/Memcached.pm 2007-07-17 10:47:40.000000000 -0700 +++ Cache-Memcached-1.24.patched/lib/Cache/Memcached.pm 2009-02-26 16:39:33.462541000 -0800 @@ -25,6 +25,7 @@ bucketcount _single_sock _stime connect_timeout cb_connect_fail parser_class + last_res }; # flag definitions @@ -86,6 +87,12 @@ return $self; } +sub last_res { + my Cache::Memcached $self = shift; + + return $self->{last_res}; +} + sub set_pref_ip { my Cache::Memcached $self = shift; $self->{'pref_ip'} = shift; @@ -399,6 +406,9 @@ return undef; } + $self->{last_res} = $ret; + $self->{last_res} =~ s/\r\n$//; + return $ret; } @@ -1090,6 +1100,16 @@ values are capped at 0. If server value is 1, a decrement of 2 returns 0, not -1. +=item C<last_res> + +$memd->last_res + +This method returns the status string of the last operation except for get(s). +This allows you, for instance, to differentiate between C<NOT_FOUND> and a +protocol error. The trailing \r\n has already been removed. See the +memcached protocol docs for possible return values for each command: +L<http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt> + =item C<stats> $memd->stats([$keys]);
Here's the patch again - seems RT doesn't recognise .patch files as txt
--- Cache-Memcached-1.24/lib/Cache/Memcached.pm 2007-07-17 10:47:40.000000000 -0700 +++ Cache-Memcached-1.24.patched/lib/Cache/Memcached.pm 2009-02-26 16:39:33.462541000 -0800 @@ -25,6 +25,7 @@ bucketcount _single_sock _stime connect_timeout cb_connect_fail parser_class + last_res }; # flag definitions @@ -86,6 +87,12 @@ return $self; } +sub last_res { + my Cache::Memcached $self = shift; + + return $self->{last_res}; +} + sub set_pref_ip { my Cache::Memcached $self = shift; $self->{'pref_ip'} = shift; @@ -399,6 +406,9 @@ return undef; } + $self->{last_res} = $ret; + $self->{last_res} =~ s/\r\n$//; + return $ret; } @@ -1090,6 +1100,16 @@ values are capped at 0. If server value is 1, a decrement of 2 returns 0, not -1. +=item C<last_res> + +$memd->last_res + +This method returns the status string of the last operation except for get(s). +This allows you, for instance, to differentiate between C<NOT_FOUND> and a +protocol error. The trailing \r\n has already been removed. See the +memcached protocol docs for possible return values for each command: +L<http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt> + =item C<stats> $memd->stats([$keys]);
Updated patch - neglected to clear out the last_res property at the start of write_or_read.
@@ -25,6 +25,7 @@ bucketcount _single_sock _stime connect_timeout cb_connect_fail parser_class + last_res }; # flag definitions @@ -86,6 +87,12 @@ return $self; } +sub last_res { + my Cache::Memcached $self = shift; + + return $self->{last_res}; +} + sub set_pref_ip { my Cache::Memcached $self = shift; $self->{'pref_ip'} = shift; @@ -339,6 +346,8 @@ my $res; my ($ret, $offset) = (undef, 0); + $self->{last_res} = undef; + $check_complete ||= sub { return (rindex($ret, "\r\n") + 2 == length($ret)); }; @@ -399,6 +408,9 @@ return undef; } + $self->{last_res} = $ret; + $self->{last_res} =~ s/\r\n$//; + return $ret; } @@ -1090,6 +1102,16 @@ values are capped at 0. If server value is 1, a decrement of 2 returns 0, not -1. +=item C<last_res> + +$memd->last_res + +This method returns the status string of the last operation except for get(s). +This allows you, for instance, to differentiate between C<NOT_FOUND> and a +protocol error. The trailing \r\n has already been removed. See the +memcached protocol docs for possible return values for each command: +L<http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt> + =item C<stats> $memd->stats([$keys]);
This patch is being tracked here: http://codereview.appspot.com/22052/show