Feature/cache improvements 2 (#1067)

* New Mode to control queryCache behavior

* Collections form the cache have to be read only

* findCount not queried in query cache

* return modifiable collections from the cache

* FIX: Compile errors

* No effective code change: reformat code / javadoc
This commit is contained in:
Roland Praml
2017-09-12 23:40:18 +12:00
committed by Rob Bygrave
parent b8e1dffca2
commit a6e4e181bf
18 changed files with 587 additions and 38 deletions
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.querydefn;
import io.ebean.CacheMode;
import io.ebean.EbeanServer;
import io.ebean.Expression;
import io.ebean.ExpressionFactory;
@@ -195,7 +196,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
private boolean excludeBeanCache;
private Boolean useQueryCache;
private CacheMode useQueryCache = CacheMode.OFF;
private Boolean readOnly;
@@ -1094,9 +1095,13 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
}
@Override
public boolean isUseQueryCache() {
public CacheMode getUseQueryCache() {
// not using L2 cache for asDraft() query
return !isAsDraft() && Boolean.TRUE.equals(useQueryCache);
if (isAsDraft()) {
return CacheMode.OFF;
} else {
return useQueryCache;
}
}
@Override
@@ -1106,7 +1111,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
}
@Override
public DefaultOrmQuery<T> setUseQueryCache(boolean useQueryCache) {
public DefaultOrmQuery<T> setUseQueryCache(CacheMode useQueryCache) {
this.useQueryCache = useQueryCache;
return this;
}