use of com.alicp.jetcache.RefreshPolicy in project jetcache by alibaba.
the class CacheConfigUtil method parseRefreshPolicy.
public static RefreshPolicy parseRefreshPolicy(CacheRefresh cacheRefresh) {
RefreshPolicy policy = new RefreshPolicy();
TimeUnit t = cacheRefresh.timeUnit();
policy.setRefreshMillis(t.toMillis(cacheRefresh.refresh()));
if (!CacheConsts.isUndefined(cacheRefresh.stopRefreshAfterLastAccess())) {
policy.setStopRefreshAfterLastAccessMillis(t.toMillis(cacheRefresh.stopRefreshAfterLastAccess()));
}
if (!CacheConsts.isUndefined(cacheRefresh.refreshLockTimeout())) {
policy.setRefreshLockTimeoutMillis(t.toMillis(cacheRefresh.refreshLockTimeout()));
}
return policy;
}
use of com.alicp.jetcache.RefreshPolicy 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