#684 - Refactor - rename @CacheStrategy to @Cache ... require explicit enableQueryCache=true for query cache use

This commit is contained in:
Robin Bygrave
2016-04-29 21:52:50 +12:00
parent a6d276d4d3
commit 5bcfce9cd4
63 changed files with 719 additions and 844 deletions
@@ -1,5 +1,6 @@
package com.avaje.ebeaninternal.server.deploy.meta;
import com.avaje.ebean.annotation.Cache;
import com.avaje.ebeaninternal.api.ConcurrencyMode;
import com.avaje.ebean.annotation.DocStore;
import com.avaje.ebean.annotation.DocStoreMode;
@@ -153,7 +154,7 @@ public class DeployBeanDescriptor<T> {
private final List<BeanQueryAdapter> queryAdapters = new ArrayList<BeanQueryAdapter>();
private final List<BeanPostLoad> postLoaders = new ArrayList<BeanPostLoad>();
private final CacheOptions cacheOptions = new CacheOptions();
private CacheOptions cacheOptions = CacheOptions.NO_CACHING;
/**
* If set overrides the find implementation. Server side only.
@@ -442,6 +443,24 @@ public class DeployBeanDescriptor<T> {
this.inheritInfo = inheritInfo;
}
/**
* Enable L2 bean and query caching based on Cache annotation.
*/
public void setCache(Cache cache) {
String naturalKey = null;
if (cache.naturalKey().length() > 0) {
// find the property and mark as natural key property
String propName = cache.naturalKey().trim();
DeployBeanProperty beanProperty = getBeanProperty(propName);
if (beanProperty != null) {
beanProperty.setNaturalKey();
naturalKey = propName;
}
}
this.cacheOptions = new CacheOptions(cache, naturalKey);
}
/**
* Return the cache options.
*/