3rd-Eden / memcached

A fully featured Memcached client build on top of Node.js. Build with scaling in mind so it will support Memcached clusters and consistent hashing.
MIT License
1.31k stars 276 forks source link

Should this be binary instead of utf-8 ? #325

Closed mrx8 closed 6 years ago

mrx8 commented 6 years ago

https://github.com/3rd-Eden/memcached/blob/96b962d2c2c25f623e8d5247c6fda90e83cca3b8/lib/memcached.js#L183

I used your library to get key/values from my memcached-cluster. The values are binary-strings, which were filled by C-program with length 516 bytes. After I get such a key/value with you library, the resulting string is only 512 bytes. I looked in your code and set the encoding in lin 183 explicit to "binary". This fixed my problems. IMHO encoding must not be set to utf-8 because the payload in values are binary. If only your client is used to get/set key/values, then it works. Perhaps you should always encode/decode strings as Buffers ?

mapleeit commented 6 years ago

same as #320

mapleeit commented 6 years ago

Have supported encoding config.