#683 - Refactor - rename @CacheTuning to @CacheBeanTuning ... for consistency

This commit is contained in:
Robin Bygrave
2016-04-29 09:48:36 +12:00
parent 5b100e6d37
commit a6d276d4d3
6 changed files with 26 additions and 25 deletions
@@ -6,14 +6,15 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Specify cache tuning for a specific entity type.
* Cache tuning hints for the L2 bean cache of a specific entity type.
* <p>
* If this is not specified then the system default settings are used.
* Note that this is not useful when distributed L2 bean caches are used like
* ElasticSearch, Hazelcast, Ignite etc.
* </p>
*/
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface CacheTuning {
public @interface CacheBeanTuning {
/**
* The maximum size for the cache.
@@ -1,7 +1,7 @@
package com.avaje.ebean.cache;
import com.avaje.ebean.annotation.CacheQueryTuning;
import com.avaje.ebean.annotation.CacheTuning;
import com.avaje.ebean.annotation.CacheBeanTuning;
/**
* Options for controlling a cache.
@@ -23,11 +23,11 @@ public class ServerCacheOptions {
/**
* Create from the cacheTuning deployment annotation.
*/
public ServerCacheOptions(CacheTuning cacheTuning) {
this.maxSize = cacheTuning.maxSize();
this.maxIdleSecs = cacheTuning.maxIdleSecs();
this.maxSecsToLive = cacheTuning.maxSecsToLive();
this.trimFrequency = cacheTuning.trimFrequency();
public ServerCacheOptions(CacheBeanTuning tuning) {
this.maxSize = tuning.maxSize();
this.maxIdleSecs = tuning.maxIdleSecs();
this.maxSecsToLive = tuning.maxSecsToLive();
this.trimFrequency = tuning.trimFrequency();
}
/**
@@ -1,7 +1,7 @@
package com.avaje.ebeaninternal.server.cache;
import com.avaje.ebean.annotation.CacheQueryTuning;
import com.avaje.ebean.annotation.CacheTuning;
import com.avaje.ebean.annotation.CacheBeanTuning;
import com.avaje.ebean.cache.ServerCache;
import com.avaje.ebean.cache.ServerCacheFactory;
import com.avaje.ebean.cache.ServerCacheOptions;
@@ -109,9 +109,9 @@ public class DefaultCacheHolder {
}
private ServerCacheOptions getBeanOptions(Class<?> cls) {
CacheTuning cacheTuning = cls.getAnnotation(CacheTuning.class);
if (cacheTuning != null) {
ServerCacheOptions o = new ServerCacheOptions(cacheTuning);
CacheBeanTuning tuning = cls.getAnnotation(CacheBeanTuning.class);
if (tuning != null) {
ServerCacheOptions o = new ServerCacheOptions(tuning);
o.applyDefaults(defaultOptions);
return o;
}
@@ -1,7 +1,7 @@
package com.avaje.ebeaninternal.server.deploy.parse;
import com.avaje.ebean.annotation.CacheStrategy;
import com.avaje.ebean.annotation.CacheTuning;
import com.avaje.ebean.annotation.CacheBeanTuning;
import com.avaje.ebean.annotation.DbComment;
import com.avaje.ebean.annotation.DocStore;
import com.avaje.ebean.annotation.Draftable;
@@ -203,21 +203,21 @@ public class AnnotationClass extends AnnotationParser {
}
CacheStrategy cacheStrategy = cls.getAnnotation(CacheStrategy.class);
CacheTuning cacheTuning = cls.getAnnotation(CacheTuning.class);
if (cacheStrategy != null || cacheTuning != null) {
readCacheStrategy(cacheStrategy, cacheTuning);
CacheBeanTuning cacheBeanTuning = cls.getAnnotation(CacheBeanTuning.class);
if (cacheStrategy != null || cacheBeanTuning != null) {
readCacheStrategy(cacheStrategy, cacheBeanTuning);
}
}
private void readCacheStrategy(CacheStrategy cacheStrategy, CacheTuning cacheTuning) {
private void readCacheStrategy(CacheStrategy cacheStrategy, CacheBeanTuning cacheBeanTuning) {
if (disableL2Cache) {
return;
}
CacheOptions cacheOptions = descriptor.getCacheOptions();
if (cacheTuning != null) {
cacheOptions.setMaxSecsToLive(cacheTuning.maxSecsToLive());
cacheOptions.setMaxIdleSecs(cacheTuning.maxIdleSecs());
if (cacheBeanTuning != null) {
cacheOptions.setMaxSecsToLive(cacheBeanTuning.maxSecsToLive());
cacheOptions.setMaxIdleSecs(cacheBeanTuning.maxIdleSecs());
}
if (cacheStrategy != null) {
cacheOptions.setUseCache(cacheStrategy.useBeanCache());