diff --git a/NOTES b/NOTES
index b2020d0..a2cb1f2 100644
--- a/NOTES
+++ b/NOTES
@@ -22,6 +22,14 @@ Operation/
`-- PreparedStreamOperation
+----
+@CompoundIndex()
+create a new col in the same table called __idx_a_b_c that the hash of the concatenated values in that order is stored, create a normal index for that (CREATE INDEX ...)
+if a query matches that set of columns then use that indexed col to fetch the desired results from that table
+could also work with .in() query if materialized view exists
+----
+
+
// TODO(gburd): create a statement that matches one that wasn't prepared
//String key =
// "use " + preparedStatement.getQueryKeyspace() + "; " + preparedStatement.getQueryString();
diff --git a/helenus-core.iml b/helenus-core.iml
index 8e5de48..7b75a06 100644
--- a/helenus-core.iml
+++ b/helenus-core.iml
@@ -28,12 +28,15 @@
+
+
+
@@ -117,7 +120,6 @@
-
diff --git a/pom.xml b/pom.xml
index c1a88e5..d6a9172 100644
--- a/pom.xml
+++ b/pom.xml
@@ -158,6 +158,16 @@
ca.exprofesso
guava-jcache
1.0.4
+
+
+ com.google.guava
+ guava
+
+
+ javax.cache
+ cache-api
+
+
diff --git a/src/main/java/net/helenus/core/AbstractUnitOfWork.java b/src/main/java/net/helenus/core/AbstractUnitOfWork.java
index 4e10550..22491f7 100644
--- a/src/main/java/net/helenus/core/AbstractUnitOfWork.java
+++ b/src/main/java/net/helenus/core/AbstractUnitOfWork.java
@@ -28,6 +28,10 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
+
+import javax.cache.Cache;
+import javax.cache.CacheManager;
+
import net.helenus.core.cache.CacheUtil;
import net.helenus.core.cache.Facet;
import net.helenus.core.operation.AbstractOperation;
@@ -36,6 +40,7 @@ import net.helenus.mapping.MappingUtil;
import net.helenus.support.Either;
import net.helenus.support.HelenusException;
import org.apache.commons.lang3.SerializationUtils;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -262,7 +267,7 @@ public abstract class AbstractUnitOfWork
@Override
public void cacheDelete(String key) {
- statementCache.replace(key, deleted);
+ statementCache.put(key, deleted);
}
@Override
@@ -303,7 +308,7 @@ public abstract class AbstractUnitOfWork
@Override
public Object cacheUpdate(String key, Object value) {
- return statementCache.replace(key, value);
+ return statementCache.put(key, value);
}
@Override
@@ -315,7 +320,7 @@ public abstract class AbstractUnitOfWork
if (facet.alone()) {
String columnName = facet.name() + "==" + facet.value();
if (result == null) result = cache.get(tableName, columnName);
- cache.put(tableName, columnName, Either.left(value));
+ cache.put(tableName, columnName, Either.left(value));
}
}
}
@@ -394,7 +399,30 @@ public abstract class AbstractUnitOfWork
applyPostCommitFunctions("committed", uow.commitThunks);
});
- // Merge our cache into the session cache.
+ // Merge our statement cache into the session cache if it exists.
+ CacheManager cacheManager = session.getCacheManager();
+ if (cacheManager != null) {
+ for (Map.Entry entry : statementCache.entrySet()) {
+ String[] keyParts = entry.getKey().split("\\.");
+ if (keyParts.length == 2) {
+ String cacheName = keyParts[0];
+ String key = keyParts[1];
+ if (!StringUtils.isBlank(cacheName) && !StringUtils.isBlank(key)) {
+ Cache