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
| |   | [email protected]         | immer weniger.
__/   | http://www.hjp.at/ |   -- Matthias Kohrs in desd

Attachment: signature.asc
Description: Digital signature

Reply via email to