line(content, " QueryCache cache = graph.processor.cache;");
if(shortcut) {
line(content, " if(parent == null && listener == null && !cache.shouldCache(graph.processor, " + signature[1] + ")) {");
+ line(content, " if (SINGLE) {");
+ line(content, " " + clazz + " e = cache.peek" + clazz + "(" + signature[1] + ");");
+ line(content, " if (e != null && e.isReady()) {");
+ line(content, " " + (genReturn ? "return " : "") + "e.performFromCache(graph, procedure);");
+ if(!genReturn) line(content, " return;");
+ line(content, " }");
+ line(content, " }");
line(content, " " + (genReturn ? "return " : "") + clazz + ".computeForEach(graph, " + signature[1] + ", null, procedure);");
if(!genReturn) line(content, " return;");
line(content, " }");
line(content, "}");
line(content, "");
+ String lower = Character.toLowerCase(clazz.charAt(0)) + clazz.substring(1);
+
+ line(content, "private " + clazz + " peek" + clazz + "(" + signature[0] + ") {");
+ line(content, " synchronized(" + lower +"Map) {");
+ line(content, " return (" + clazz + ") " + lower + "Map.get(" + signature[1] + ");");
+ line(content, " }");
+ line(content, "}");
+ line(content, "");
}
public void generateRemove(StringBuilder content, String clazz, String[] signature) {
content.append("public class QueryCache extends QueryCacheBase {\n");
content.append("\n");
+
+ line(content, "private static final boolean SINGLE = true;");
+ content.append("\n");
+
line(content,"public QueryCache(QuerySupport querySupport, int threads) {");
line(content," super(querySupport, threads);");
line(content,"}");