infinispan/infinispan — pull request #1096 by ryangardner (2012-04-26 20:09:25+00:00)
Title: Allow SpringCache to be configured to use asynchronous operations

In testing with a cache that was configured to use asynchronous replication, I was seeing a fair number of exceptions in my logs about timeout waiting for keys when doing a put.

Since I was using the @Cacheable annotation to do the caching around those method calls, these exceptions were resulting in my services returning 500 errors to the client.

Poking around, it seems that using the putAsync method would make the put methods return immediately and any exception would not be in the same thread so it wouldn't matter.

For my use, a put that fails is fine - spring will just put it in the next time if there is no value in the cache.

This pull request creates a configuration parameter on the EmbeddedCacheManagerFactory and EmbeddedRemoteCacheManagerFactory for "useAsynchronousCacheOperations" which, when set to true, will use a SpringAsynchrnousCache to wrap the native cache instead of the default SpringCache.

I added unit tests around this and updated other tests.

In my own load testing environment, I'm no longer seeing the errors related to cache put key lock timeouts and the execution time for my methods has improved in cases when it would have otherwise been blocking waiting for a put.