summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorSteve Yen <steve.yen@gmail.com>2009-01-27 00:21:45 -0800
committerSteve Yen <steve.yen@gmail.com>2009-03-02 08:48:26 -0800
commit90ba3661e4a893952ddf5c475ae0d2dc5868817a (patch)
tree88dcc17575f05545264512deeb8ca32c9e87256d /scripts
parenta53e616646693ead37a0ae474c1851f287204d90 (diff)
downloadmemcached-90ba3661e4a893952ddf5c475ae0d2dc5868817a.tar.gz
memcached-tool dump command fixed for expired/evicted/deleted keys
Fixed the memcached-tool 'dump' command to handle the case when dumping keys that have expired, evicted or been deleted in the midst of the big iteration. Previously, memcached-tool would just hang in these cases. The memcached-tool uses the results from 'stats cachedump' as the keys to iterate through, and will do a 'get' on each key. The 'stats cachedump' implementation, however, does not check for expiry, which is debatably the correct thing to do.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/memcached-tool19
1 files changed, 10 insertions, 9 deletions
diff --git a/scripts/memcached-tool b/scripts/memcached-tool
index 7f91291..fc355fc 100755
--- a/scripts/memcached-tool
+++ b/scripts/memcached-tool
@@ -119,17 +119,18 @@ if ($mode eq 'dump') {
}
foreach my $k (keys(%keyexp)) {
- my $val;
print $sock "get $k\r\n";
my $response = <$sock>;
- $response =~ /VALUE (\S+) (\d+) (\d+)/;
- my $flags = $2;
- my $len = $3;
- read $sock, $val , $len;
- # get the END
- $_ = <$sock>;
- $_ = <$sock>;
- print "add $k $flags $keyexp{$k} $len\r\n$val\r\n";
+ if ($response =~ /VALUE (\S+) (\d+) (\d+)/) {
+ my $flags = $2;
+ my $len = $3;
+ my $val;
+ read $sock, $val, $len;
+ print "add $k $flags $keyexp{$k} $len\r\n$val\r\n";
+ # get the END
+ $_ = <$sock>;
+ $_ = <$sock>;
+ }
}
}
exit;