Mixed Language Environments

Steven Smith ssmith at fiveruns.com
Fri Nov 25 17:09:36 PST 2005


Hi Greg,

Thanks for the reply and explanation.  After implementing the changes  
you suggested I was able to get my test program to work.

Steven


On Nov 25, 2005, at 11:19 AM, Greg Whalin wrote:

> For complex types, the java client will use natice java  
> serialization as long as the object implement the Serializabe or  
> Externalizable interface.  For primitives, the java client will  
> store by encoding the object using code submitted by Kevin Burton.   
> This encoding saves considerable space (in Kevin's application, by  
> using this encoding, he claims his cache utilization dropped from  
> 1GB down to 144 MB).  This encoding is enabled by default, but, as  
> you have noticed is not so hot in a multi-lang environment.  The  
> default hashing for java is also not suitable for a mixed language  
> setup.  All of this is documented in the java client javadocs,  
> however, it is relatively simple to configure the java client for a  
> mixed lang env.
>
>
> String[] serverlist =
> 	Global.getInstance().getProperty( "memcached.servers" ).split( "," );
> SockIOPool pool = SockIOPool.getInstance();
> pool.setServers( serverList );
> pool.setInitConn( 10 );
> pool.setMinConn( 5 );
> pool.setMaxConn( 250 );
> pool.setNagle( false );
>
> // for compat
> pool.setHashingAlg( SockIOPool.NEW_COMPAT_HASH )l
>
> pool.initialize();
>
> static MemCachedClient mcc = new MemCachedClient();
>
> // for compat
> mcc.setPrimitiveAsString( true );
>
>
> That should do it.
>
> Greg
>
> Steven Smith wrote:
>> Thanks for the reply Martin.
>> I was experimenting with simple types (integers, strings) and had  
>> no  problem accessing the values stored by a Java client from a  
>> Ruby  client, but not vice versa.  The Java client could see the  
>> keys, but  not decode the data.  Not sure if the Java client is  
>> intended to be  used in mixed language environments, however.
>> On Nov 25, 2005, at 2:20 AM, Martin Atkins wrote:
>>> Steven Smith wrote:
>>>
>>>> Is memcached intended to be used in mixed language  
>>>> environments,   i.e.,
>>>> where there are Ruby clients, Java clients, etc. sharing the  same
>>>> caches?  My suspicion is that there would be potential  
>>>> decoding   issues,
>>>> etc. when getting a value in one language environment which  had  
>>>> been
>>>> set by another.  Just FYI, I've successfully installed   
>>>> memcached and
>>>> have it working from with both Java and Ruby clients,  but have   
>>>> ran into
>>>> problems getting values in the Java environment  that were set  
>>>> with a
>>>> Ruby client.
>>>>
>>>
>>> You would have to write your own serialization code for complex  
>>> types
>>> which can then be supported across multiple languages. Most of the
>>> client libraries out there just use whatever serialization  
>>> mechanisms
>>> are provided by the language's stock runtime libraries.
>>>
>>> All of the clients I'm aware of store plain integers and strings as
>>> strings, though. Aside from character encoding issues, these simple
>>> types should be fine. Caveat: I've never looked at the Java  
>>> client  library.
>>>
>



More information about the memcached mailing list