using memcache with multi ClientAPI multi platforms and languages

When your system is large, compose by several programs, in several languages. If every programs need to access memcacheD, you should use the correct ClientAPI to make them talk with each other.
Of course, if you set value by PHP, you get value by PHP, it works. If you set value by Java, then you get value by other Java program, it work too.

BUT, this time (this post time), if PHP says, maybe Java can’t hear, C# can’t here, and vice versa.

in PHP, $memcacheClient->set(“test”,”lockevn”);     // it will go to memcache server

in Java, Object oValue = oMemcacheClient.get(“test”) ;      // it will return null, supprise!!! @:@

I have some experience with Java, PHP. PHP website (using default pecl extension module) set value to memcache, if Java program need to get that value, you should use ClientAPI (at the time of this post). The other won’t work. Follow this link to get more info.

I do not test .NET client

You also need to store value as native format, only use 32bit integer, or string. If you put PHP object, Java program can not understand it, neither the C# program.

If your really need to store object, serialize it (to XML, JSON, … encode with UTF-8) BEFORE put it in memcache. The others must deserialize after get that value. Believe me, do that will save you a lot of time.

There is a similar alternative project on Windows: Velocity from MS

And an alternate one


memcache is good, but it make only to store data, only data, it does not like “object” things, don’t push it too hard. If you want some program say and other “different language” program hear, check it carefully, ask the ClientAPI author if it does not work. You should use native data format for value (int and string only), do serialize by yourself if you want to store data object.