Hi HP, I have solved the problem yet, but still many thanks for your reply which helps me clarify the storage of string in Memcached. You r right that "10101010" is not a binary string, it is just an ascii string and looks like a binary sequence ...
I used libmemcache c++ client in my code, the return of "memcache_get" call is char*, i just used string value = string(xxx) to convert the char* to a string. But actually the binary string contains '\r\n' thus i just got the string before the first '\r\n' and lost the rest data, that's the key point to the problem. Now i just used string.append(xxx, length) to get the whole binary sequence. Thank you~! Daniel. 在 2013年5月5日星期日UTC-4上午5时06分11秒,Peter J. Holzer写道: > > On 2013-05-04 12:31:46 -0700, daniel guo wrote: > > In my project i want to store a binary string (string like > "010101010101") to > > "010101010101" doesn't look like what most programmers would consider a > binary string. It looks like a string consisting entirely of printable > characters which just happen to be "0" and "1". > > A binary string usually means a string where all possible byte values > are allowed in any combination. I assume that this is what you meant > despite your example. > > > memcached and then retrieve it back when needed, > > Memcached treats all strings as binary. The only limitation is the > length (and that is configurable). Up to that length you can store and > retrieve any byte string - memcached doesn't care. Indeed many client > libraries compress values before storing them. > > > it seems that i can store the string successfully to memcached as "get > xxx" > > gives me a result similar to original one, > > but when i use "memcached_get" function to get the result in my code, > the > > return string is not the same to the original binary string, > > the length of the return string is much shorter than the original one. > > > > Who can tell my why, is it possible to store binary string to memcached? > > It is possible. > > We can't tell you why you get a shorter string back because: > > * You didn't tell us what the original string was > * You didn't tell us what the shorter string was > * You didn't tell us what client library you are using > * You didn't tell us what programming language you are using > * You didn't post any code to reproduce the problem > > hp > > -- > _ | Peter J. Holzer | Der eigene Verstand bleibt gefühlt messer- > |_|_) | Sysadmin WSR | scharf. Aber die restliche Welt blickt's > | | | h...@hjp.at <javascript:> | immer weniger. > __/ | http://www.hjp.at/ | -- Matthias Kohrs in desd > -- --- You received this message because you are subscribed to the Google Groups "memcached" group. To unsubscribe from this group and stop receiving emails from it, send an email to memcached+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.