Alternative java client

Dustin Sallings dustin at
Fri Mar 30 20:45:31 UTC 2007

	In case anyone's interested, I wrote a java 5 memcached client a  
while back that I've had a reasonable amount of success with.

	The goal was to have an asynchronous single-threaded client that was  
resilient to server faults.  I seem to have met that goal for myself  
and would like to share it with anyone else who's interested.

	The overview page (maven1) can be found here:

	If you want to grab the source and play around, it's here:

	Latest binary release comes out of my maven 1 repo:

	Example synchronous usage (from the javadocs):

   MemcachedClient c=new MemcachedClient(
       new InetSocketAddress("hostname", portNum));

   // Store a value (async) for one hour
   c.set("someKey", 3600, someObject);
   // Retrieve a value.
   Object myObject=c.get("someKey");

	Example asynchronous usage (assuming a server is slow or broken):

   // Try to get a value, for up to 5 seconds, and cancel if it  
doesn't return
   Object myObj=null;
   Future<Object> f=c.asyncGet("someKey");
   try {
       myObj=f.get(5, TimeUnit.SECONDS);
   } catch(TimeoutException e) {
       // Since we don't need this, go ahead and cancel the  
operation.  This
       // is not strictly necessary, but it'll save some work on the  
       // Do other timeout related stuff

Dustin Sallings

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the memcached mailing list