This content has been marked as final. Show 1 reply
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.