dustin/java-memcached-client — pull request #11 by sitano (2012-03-23 11:08:26+00:00)
Title: Async. event-driven model support

Hi,

These are a couple of changes that I did to the memcached client library for our internal use at Neodinamika.

At present, java-memcached-client exposes it's async api through Future mechanics. It's great that client built async. way, but these native java future objects are giving us the only way to go with them: wait on get for the result blocking current thread for a timeout. No listeners, no callbacks, just block or ask in a while.

And this is why it is not async. You should have thread swarm pushing requests to the client and waiting on results to be processed further any async. way.

I would like to have an option to pass a callback to the client with the request, so when it's ready, callback will be invoked. Callback will allow me to send any Actor in the system a Message that result of op have been gotten. So, this is event handler and it allows me not to have a lot of threads waiting on futures of results.

Here it is an extension to MemcacheClient interface introducing operations with OperationListener handler.
OperationListener has the only one method onComplete. And it will be called when OperationImpl.Callback get a complete call with Latcher at 0.