elbart / node-memcache

node.js memcached client
285 stars 64 forks source link

handle_get() to truncate data on last "\nEND\n" #37

Open dylancwood opened 10 years ago

dylancwood commented 10 years ago

Searching the buffer string for "END" causes problems if the data inside contains the substring "END". For example, if I retrieve the string "Please do not EXTEND beyond the edge" from my memcached server, the "END" in EXTEND will signal the end of the data, and only "Please do Not E" will be returned. This is fixed by looking for crlf + "END" + crlf. On the off chance that the data contains that string, it is advisable to search for the last occurrence of it, instead of the first.

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()

dylancwood commented 10 years ago

Hi Elbart,

Thank you for making the node-memcache module! This is my first pull-request to someone else's code, so please let me know how I did, and if there is anything else I can do to make my simple change better. Thanks again!

jisqyv commented 5 years ago

@dylancwood See #46 for a better approach