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]);