Search in sources :

Example 1 with RefreshPolicy

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;
}
Also used : TimeUnit(java.util.concurrent.TimeUnit) RefreshPolicy(com.alicp.jetcache.RefreshPolicy)

Example 2 with RefreshPolicy

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;
}
Also used : CachedAnnoConfig(com.alicp.jetcache.anno.support.CachedAnnoConfig) PenetrationProtectConfig(com.alicp.jetcache.anno.support.PenetrationProtectConfig) RefreshPolicy(com.alicp.jetcache.RefreshPolicy)

Aggregations

RefreshPolicy (com.alicp.jetcache.RefreshPolicy)2 CachedAnnoConfig (com.alicp.jetcache.anno.support.CachedAnnoConfig)1 PenetrationProtectConfig (com.alicp.jetcache.anno.support.PenetrationProtectConfig)1 TimeUnit (java.util.concurrent.TimeUnit)1