[jboss-user] [JBoss Cache Users] - Re: What is an invocation, and the related option override?

mircea.markus do-not-reply at jboss.com
Thu Oct 1 06:23:16 EDT 2009

it only makes sense to use setForceWriteLock(true) on read. Normally when you do an cache.get(fqn) an read lock is aquired, but setting the forceWriteLock to true would force a write lock acquisition. when you do a put(fqn)(generally a write), a WL (write lock) is acquired so having the flag is redundant. As a general rule, the forceWriteLock only apply for one call, i.e. for one invocation. 
  |                     // force write lock even on read operations
  |                     cache.getInvocationContext().getOptionOverrides().setForceWriteLock(true);
  |                     // read node
  |                     Object value = cache.get(myFqn, "key");
  |                     Object value = cache.get(myFqn2, "key");
  |                     tm.commit();

In this example a WL is acquired for myFqn and a RL is acquired for myFqn2

anonymous wrote : In other words, once I set the "setForceWriteLock(true)", all future cache related operations in this thread will see this option set to "true". No. Only the next call, after that the flag is cleaned. As mentioned in the previous post, an invocation is an call to the cache.

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

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

More information about the jboss-user mailing list