Author: manik.surtani(a)jboss.com
Date: 2008-01-03 20:59:48 -0500 (Thu, 03 Jan 2008)
New Revision: 4973
Modified:
core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
Log:
JBCACHE-881 - cache node references in invocation context to save on multiple expensive
cache.peek() calls.
Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-01-04 01:59:29
UTC (rev 4972)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-01-04 01:59:48
UTC (rev 4973)
@@ -11,6 +11,8 @@
import org.jboss.cache.transaction.GlobalTransaction;
import javax.transaction.Transaction;
+import java.util.HashMap;
+import java.util.Map;
/**
* This context holds information specific to a method invocation.
@@ -28,12 +30,49 @@
private boolean localRollbackOnly;
private MethodCall methodCall;
+ // used to store cache peeks within the scope of a single context. Performing a cache
peek can be a huge bottle neck.
+ // See JBCACHE-811
+ private Map<Fqn, NodeSPI> peekedNodes = new HashMap<Fqn, NodeSPI>();
+
+ /**
+ * Retrieves a node that may have previously been "peeked" within the scope
of the same invocation.
+ *
+ * @param f fqn of node to find
+ * @return node, if previously peeked, or null if not.
+ * @since 2.1.0
+ */
+ public NodeSPI getPeekedNode(Fqn f)
+ {
+ return peekedNodes.get(f);
+ }
+
+ /**
+ * Adds a node to the previously peeked list.
+ *
+ * @param n node to add
+ * @param f fqn of node
+ * @since 2.1.0
+ */
+ public void savePeekedNode(NodeSPI n, Fqn f)
+ {
+ peekedNodes.put(f, n);
+ }
+
+ /**
+ * Wipe list of previously peeked nodes.
+ *
+ * @since 2.1.0
+ */
+ public void wipePeekedNodes()
+ {
+ peekedNodes.clear();
+ }
+
public void setLocalRollbackOnly(boolean localRollbackOnly)
{
this.localRollbackOnly = localRollbackOnly;
}
-
/**
* Retrieves the transaction associated with this invocation
*