[jboss-user] [JBossCache] - Patch adding transactional putSilent() method

Cyberax do-not-reply at jboss.com
Sat Sep 8 11:32:35 EDT 2007


Please, can you review this patch for addition into the mainline JBoss Cache?

The motivation for this patch

Currently, JBoss Cache adapter for Hibernate uses putForExternalRead() method. This method suspends and then resumes the current transaction and this is slow with some transaction managers, particularly with ones that support transaction recovery. For example, with Atomikos Transaction Manager it takes 25 seconds with putForExternalRead() on my computer to load a big Hibernate model versus 3 seconds with simple put() method in org.hibernate.cache.Cache implementation.

But simple put() method can't be used reliably, because DataVersioningException will be thrown if another thread has loaded the same object and put it in the cache.

Patch details

I've developed this patch to solve this problem. It adds putSilently() method to Cache interface, this method works exactly like putForExternalRead() except that it does not suspend and resume the current transaction. Instead, workspace nodes are marked so they can be ignored during optimistic validation if it fails.

I don't have much experience with JBoss Cache, but this patch works for me (or at least looks like it is working :) ). If the general idea is OK, I'll add mode documentation and unit tests for inclusion into the official JBoss Cache package.

You can get the patch here: http://sd-sup.staffdirector.net/cache.patch

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4082353#4082353

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4082353



More information about the jboss-user mailing list