[jboss-user] [JBossCache] - Re: New Bie JBoss Cache Replication

genman do-not-reply at jboss.com
Tue Feb 26 14:07:07 EST 2008


Here's the thing. Machine 1 might store 10, but then if you call Machine 2, it might store 0. What you need to do is more like:

  | Integer count = (Integer)cache.get("/a/b/c", "Key1");
  | if (count == null) // initialize
  |    count = 0;
  | count = count + 1;
  | cache.put("/a/b/c", "Key1", count);
  | 
But there's a potential race condition here. Use pessimistic locking and transactions to ensure this is atomic.




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

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



More information about the jboss-user mailing list