|
@@ -2,7 +2,6 @@ package com.persagy.fm.translate.aop;
|
|
|
|
|
|
import com.google.common.cache.Cache;
|
|
import com.google.common.cache.Cache;
|
|
import com.google.common.cache.CacheBuilder;
|
|
import com.google.common.cache.CacheBuilder;
|
|
-import com.persagy.fm.common.helper.SpringHelper;
|
|
|
|
import com.persagy.fm.translate.helper.TranslatorHelper;
|
|
import com.persagy.fm.translate.helper.TranslatorHelper;
|
|
import com.persagy.fm.translate.model.ITransable;
|
|
import com.persagy.fm.translate.model.ITransable;
|
|
import com.persagy.fm.translate.model.Trans;
|
|
import com.persagy.fm.translate.model.Trans;
|
|
@@ -30,17 +29,17 @@ import java.util.List;
|
|
@Slf4j
|
|
@Slf4j
|
|
public class TranslateAopAspect implements Ordered {
|
|
public class TranslateAopAspect implements Ordered {
|
|
|
|
|
|
- /**
|
|
|
|
- * 翻译描述信息缓存
|
|
|
|
- */
|
|
|
|
|
|
+ /** 缓存池大小 */
|
|
|
|
+ private final int CACHE_COUNT = 100;
|
|
|
|
+
|
|
|
|
+ /** 翻译描述信息缓存 */
|
|
private Cache<String,List<TransMeta>> transCach;
|
|
private Cache<String,List<TransMeta>> transCach;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 构造方法,初始化缓存
|
|
* 构造方法,初始化缓存
|
|
*/
|
|
*/
|
|
public TranslateAopAspect(){
|
|
public TranslateAopAspect(){
|
|
- int count = SpringHelper.getInt("translate.cache.size",100);
|
|
|
|
- transCach = CacheBuilder.newBuilder().initialCapacity(count/2).maximumSize(count).build();
|
|
|
|
|
|
+ transCach = CacheBuilder.newBuilder().initialCapacity(CACHE_COUNT/2).maximumSize(CACHE_COUNT).build();
|
|
}
|
|
}
|
|
|
|
|
|
@Pointcut("@annotation(com.persagy.fm.translate.model.Transes)||@annotation(com.persagy.fm.translate.model.Trans)")
|
|
@Pointcut("@annotation(com.persagy.fm.translate.model.Transes)||@annotation(com.persagy.fm.translate.model.Trans)")
|