Skip to content
This repository was archived by the owner on Feb 13, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/memcache.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,13 @@ Client.prototype.handle_get = function(buffer) {
var end_indicator_len = 3;
var result_len = 0;

if (buffer.indexOf('END') == 0) {
if (buffer.indexOf('END' + crlf) == 0) {
return [result_value, end_indicator_len + crlf_len];
} else if (buffer.indexOf('VALUE') == 0 && buffer.indexOf('END') != -1) {
} else if (buffer.indexOf('VALUE') == 0
&& buffer.indexOf(crlf + 'END' + crlf) != -1) {
first_line_len = buffer.indexOf(crlf) + crlf_len;
var end_indicator_start = buffer.indexOf('END');
result_len = end_indicator_start - first_line_len - crlf_len;
var end_indicator_start = buffer.lastIndexOf(crlf + 'END' + crlf);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can tell, there is no way to retrieve multiple values with a single get request, so looking for the last instance of crlf + "END" + crlf should be fine. However, if I am misinterpreting, and the code needs to be able to handle multiple VALUE...END pieces, let me know and I will change lastIndexOf() to indexOf()

result_len = end_indicator_start - first_line_len;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the index retrieved on the above line now includes a crlf, there is no need to subtract the crlf_len.

result_value = buffer.substr(first_line_len, result_len);
return [result_value, first_line_len + parseInt(result_len, 10) + crlf_len + end_indicator_len + crlf_len]
} else {
Expand Down