I doubt this is due to to serialization issues, though it could be. By default, the Java client hashes using the default String hashing as it is fast and pretty good for even key distribution. The other clients have all agreed on a common hashing algorithm. The java client supports this as well, but you need to configure it to use it. So, you should:
<br><br>String[] serverlist = { "localhost:11001" };<br>SockIOPool memcached_pool = SockIOPool.getInstance();<br>memcached_pool.setServers( serverlist );<br>memcached_pool.<span>setHashingAlg( SockIOPool.NEW_COMPAT_HASH
);<br></span>memcached_pool.initialize();<br><br>MemCachedClient mc = new MemCachedClient();<br>mc.<span>setPrimitiveAsString(true);<br></span><br>This sets the hashing alg to the compat one (which I assume is used by the PHP client), as well as stores all primitives as strings, which I think the PHP client does as well.
<br><br>gw<br><br><div><span class="gmail_quote">On 4/9/07, <b class="gmail_sendername">Arnaud Connois</b> <<a href="mailto:arnaud-memcached@connois.com">arnaud-memcached@connois.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Hi all,<br><br>I've been using memcached for many year with great success with PHP.<br><br>I'm building now a new application based on the Java API of Memcached<br>which is going to run in background of my website
<br>(Apache/PHP/Mysql/Memcached) to generate complex data structures out of<br>existing structures already in the cache.<br><br>I've plugged into my mysql database quite easily, and I am now trying to<br>plug into memcached. I'm kind of stuck at a very basic level to retreive
<br>data stored previously from PHP, probably beacuse of the fact that I'm<br>not very used to Java, and more to PHP...<br><br>So here is the idea :<br><br>I have some arrays stored by php in the memcached and I'm trying to read
<br>them from the Java API...<br><br>Here is a sample code...<br><br> String[] serverlist = { "localhost:11001" };<br> SockIOPool memcached_pool = SockIOPool.getInstance();<br> memcached_pool.setServers( serverlist );
<br> memcached_pool.initialize();<br><br> MemCachedClient mc = new MemCachedClient();<br><br> Object myarray = mc.get( "list__2__smileys_to" );<br> System.out.println( "Query Result : " + myarray );
<br><br>I get a null result...<br><br>Query Result : null<br><br>I guess it cannot make sence of the serialized data...<br><br>To make sure my structiure was there and readable I tried with<br>"asString" set to TRUE in the get method :
<br><br> String mystring = (String)mc.get( "list__2__smileys_to", null,<br>true );<br> System.out.println( "Query Result : " + mystring );<br><br>and I get a correct result :<br><br>com.danga.MemCached.MemCachedClient
Mon Apr 09 15:57:11 CEST 2007 - ++++<br>retrieving object and stuffing into a string.<br>Query Result :<br>a:15:{i:11;s:1:"3";i:3;s:1:"4";i:7;s:1:"3";i:9;s:1:"4";i:10;s:1:"3";i:21;s:1:"1";i:24;s:1:"4";i:25;s:1:"4";i:30;s:1:"3";i:19;s:1:"1";i:18;s:1:"0";i:17;s:1:"6";i:16;s:1:"1";i:14;s:1:"4";i:1;s:1:"3";}
<br><br> - How can I use this data store as a PHP array from the Java API and<br>have the serialised array being store into a Java object ?<br> - Which java object showld I use ?<br> - What synthax shoud I use ?<br><br>I'm sure we have a few Java gurus on this list who are gonna fix that
<br>for me in a few minutes...<br><br>Many Thanks<br><br>Arnaud<br><br><br><br><br><br><br></blockquote></div><br><br clear="all"><br>-- <br>Greg Whalin