Skip to content
Snippets Groups Projects

F fix pipeline

Merged Henrik tom Wörden requested to merge f-fix-pipeline into dev
3 files
+ 75
4
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -39,6 +39,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.apache.commons.jcs.access.behavior.ICacheAccess;
@@ -238,6 +239,14 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
*/
private boolean cachable = true;
/**
* Tags the query cache and is renewed each time the cache is being cleared, i.e. each time the
* database is being updated.
*
* <p>As the name suggests, the idea is similar to the ETag header of the HTTP protocol.
*/
private static String cacheETag = UUID.randomUUID().toString();
public Type getType() {
return this.type;
}
@@ -668,6 +677,7 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
/** Remove all cached queries from the cache. */
public static void clearCache() {
cacheETag = UUID.randomUUID().toString();
cache.clear();
}
@@ -678,10 +688,12 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
* @param resultSet
*/
private void setCache(String key, List<IdVersionPair> resultSet) {
if (resultSet instanceof Serializable) {
cache.put(key, (Serializable) resultSet);
} else {
cache.put(key, new ArrayList<>(resultSet));
synchronized (cache) {
if (resultSet instanceof Serializable) {
cache.put(key, (Serializable) resultSet);
} else {
cache.put(key, new ArrayList<>(resultSet));
}
}
}
@@ -859,6 +871,7 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
ret.setAttribute("results", "0");
}
ret.setAttribute("cached", Boolean.toString(this.cached));
ret.setAttribute("etag", cacheETag);
final Element parseTreeElem = new Element("ParseTree");
if (this.el.hasErrors()) {
@@ -972,4 +985,16 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
public Role getRole() {
return this.role;
}
/**
* Return the ETag.
*
* <p>The ETag tags the query cache and is renewed each time the cache is being cleared, i.e. each
* time the database is being updated.
*
* @return The ETag
*/
public static String getETag() {
return cacheETag;
}
}
Loading