use of com.alicp.jetcache.anno.support.PenetrationProtectConfig in project jetcache by alibaba.
the class CacheConfigUtil method parsePenetrationProtectConfig.
public static PenetrationProtectConfig parsePenetrationProtectConfig(CachePenetrationProtect protectAnno) {
PenetrationProtectConfig protectConfig = new PenetrationProtectConfig();
protectConfig.setPenetrationProtect(protectAnno.value());
if (!CacheConsts.isUndefined(protectAnno.timeout())) {
long timeout = protectAnno.timeUnit().toMillis(protectAnno.timeout());
protectConfig.setPenetrationProtectTimeout(Duration.ofMillis(timeout));
}
return protectConfig;
}
use of com.alicp.jetcache.anno.support.PenetrationProtectConfig in project jetcache by alibaba.
the class CacheConfigUtil method parseCached.
private static CachedAnnoConfig parseCached(Method m) {
Cached anno = m.getAnnotation(Cached.class);
if (anno == null) {
return null;
}
CachedAnnoConfig cc = new CachedAnnoConfig();
cc.setArea(anno.area());
cc.setName(anno.name());
cc.setCacheType(anno.cacheType());
cc.setEnabled(anno.enabled());
cc.setTimeUnit(anno.timeUnit());
cc.setExpire(anno.expire());
cc.setLocalExpire(anno.localExpire());
cc.setLocalLimit(anno.localLimit());
cc.setCacheNullValue(anno.cacheNullValue());
cc.setCondition(anno.condition());
cc.setPostCondition(anno.postCondition());
cc.setSerialPolicy(anno.serialPolicy());
cc.setKeyConvertor(anno.keyConvertor());
cc.setKey(anno.key());
cc.setDefineMethod(m);
CacheRefresh cacheRefresh = m.getAnnotation(CacheRefresh.class);
if (cacheRefresh != null) {
RefreshPolicy policy = parseRefreshPolicy(cacheRefresh);
cc.setRefreshPolicy(policy);
}
CachePenetrationProtect protectAnno = m.getAnnotation(CachePenetrationProtect.class);
if (protectAnno != null) {
PenetrationProtectConfig protectConfig = parsePenetrationProtectConfig(protectAnno);
cc.setPenetrationProtectConfig(protectConfig);
}
return cc;
}
Aggregations