當前位置: 首頁>>代碼示例>>Java>>正文


Java Duration.isEternal方法代碼示例

本文整理匯總了Java中javax.cache.expiry.Duration.isEternal方法的典型用法代碼示例。如果您正苦於以下問題:Java Duration.isEternal方法的具體用法?Java Duration.isEternal怎麽用?Java Duration.isEternal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.cache.expiry.Duration的用法示例。


在下文中一共展示了Duration.isEternal方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeDuration

import javax.cache.expiry.Duration; //導入方法依賴的package包/類
/**
 * @param out Output stream.
 * @param duration Duration.
 * @throws IOException If failed.
 */
private void writeDuration(ObjectOutput out, @Nullable Duration duration) throws IOException {
    if (duration != null) {
        if (duration.getDurationAmount() == 0L) {
            if (duration.isEternal())
                out.writeLong(0);
            else
                out.writeLong(CU.TTL_ZERO);
        }
        else
            out.writeLong(duration.getTimeUnit().toMillis(duration.getDurationAmount()));
    }
}
 
開發者ID:apache,項目名稱:ignite,代碼行數:18,代碼來源:IgniteExternalizableExpiryPolicy.java

示例2: getCreatedExpireTime

import javax.cache.expiry.Duration; //導入方法依賴的package包/類
private long getCreatedExpireTime() {
    if (policy == null) {
        return -1;
    }
    Duration res = policy.getExpiryForCreation();
    if (res == null || res.isEternal()) {
        return -1;
    }
    if (res.isZero()) {
        return 0;
    }
    return TimeUnit.MILLISECONDS.convert(res.getDurationAmount(), res.getTimeUnit());
}
 
開發者ID:diennea,項目名稱:blazingcache,代碼行數:14,代碼來源:BlazingCacheCache.java

示例3: getUpdatedExpireTime

import javax.cache.expiry.Duration; //導入方法依賴的package包/類
private long getUpdatedExpireTime() {
    if (policy == null) {
        return -1;
    }
    Duration res = policy.getExpiryForUpdate();
    if (res == null || res.isEternal()) {
        return -1;
    }
    if (res.isZero()) {
        return 0;
    }
    return TimeUnit.MILLISECONDS.convert(res.getDurationAmount(), res.getTimeUnit());
}
 
開發者ID:diennea,項目名稱:blazingcache,代碼行數:14,代碼來源:BlazingCacheCache.java

示例4: getAccessExpireTime

import javax.cache.expiry.Duration; //導入方法依賴的package包/類
private long getAccessExpireTime() {
    if (policy == null) {
        return -1;
    }
    Duration res = policy.getExpiryForAccess();
    if (res == null || res.isEternal()) {
        return -1;
    }
    if (res.isZero()) {
        return 0;
    }
    return TimeUnit.MILLISECONDS.convert(res.getDurationAmount(), res.getTimeUnit());
}
 
開發者ID:diennea,項目名稱:blazingcache,代碼行數:14,代碼來源:BlazingCacheCache.java

示例5: configureCacheBuilder

import javax.cache.expiry.Duration; //導入方法依賴的package包/類
<K, V> void configureCacheBuilder( CompleteConfiguration<K, V> completeConfiguration,
                                   CacheBuilder<Object, Object> cacheBuilder ) {
  ExpiryPolicy expiryPolicy = completeConfiguration.getExpiryPolicyFactory().create();

  Duration expiryForAccess = expiryPolicy.getExpiryForAccess();
  if ( expiryForAccess != null && !expiryForAccess.isEternal() ) {
    cacheBuilder.expireAfterAccess( expiryForAccess.getDurationAmount(), expiryForAccess.getTimeUnit() );
  }
  Duration expiryForUpdate = expiryPolicy.getExpiryForUpdate();
  if ( expiryForUpdate != null && !expiryForUpdate.isEternal() ) {
    cacheBuilder.expireAfterWrite( expiryForUpdate.getDurationAmount(), expiryForUpdate.getTimeUnit() );
  }
}
 
開發者ID:pentaho,項目名稱:pentaho-osgi-bundles,代碼行數:14,代碼來源:GuavaCacheManager.java

示例6: getDurationCode

import javax.cache.expiry.Duration; //導入方法依賴的package包/類
private int getDurationCode(Operation op) {
    ExpiryPolicy policy = configuration.getExpiryPolicyFactory().create();
    Duration expiryDuration = Duration.ZERO;
    switch (op) {
        case CREATION:
            expiryDuration = policy.getExpiryForCreation();
            break;
        case UPDATE:
            expiryDuration = policy.getExpiryForUpdate();
            break;
        case ACCESS:
            expiryDuration = policy.getExpiryForAccess();
            break;
    }

    if (expiryDuration == null) {
        return TTL_DONT_CHANGE;
    } else if (expiryDuration.isZero()) {
        return TTL_EXPIRED;
    } else if (expiryDuration.isEternal()) {
        return TTL_NONE;
    } else {
        long longExpiry = expiryDuration.getTimeUnit().toSeconds(expiryDuration.getDurationAmount());
        if (longExpiry <= MAX_TTL) {
            return (int) longExpiry;
        } else {
            throw new IllegalArgumentException("Explicit " + op.name()
                    + " expiry must be less than 30 days (30 * 24 * 60 * 60 = " + MAX_TTL + "sec)");
        }
    }
}
 
開發者ID:couchbaselabs,項目名稱:couchbase-java-cache,代碼行數:32,代碼來源:CouchbaseCache.java

示例7: sleepDurationTwice

import javax.cache.expiry.Duration; //導入方法依賴的package包/類
public static void sleepDurationTwice(Logger logger, Duration duration) {
    if (duration.isEternal() || duration.isZero()) {
        return;
    }

    TimeUnit timeUnit = duration.getTimeUnit();
    long timeout = duration.getDurationAmount() * 2;
    logger.info(format("Sleeping for %d %s...", timeout, timeUnit));
    sleepTimeUnit(timeUnit, timeout);
}
 
開發者ID:hazelcast,項目名稱:hazelcast-simulator,代碼行數:11,代碼來源:CacheUtils.java

示例8: convertDuration

import javax.cache.expiry.Duration; //導入方法依賴的package包/類
private java.time.Duration convertDuration(Duration duration) {
  if (duration.isEternal()) {
    return org.ehcache.expiry.ExpiryPolicy.INFINITE;
  }
  return java.time.Duration.of(duration.getDurationAmount(), ExpiryUtils.jucTimeUnitToTemporalUnit(duration.getTimeUnit()));
}
 
開發者ID:ehcache,項目名稱:ehcache3,代碼行數:7,代碼來源:ExpiryPolicyToEhcacheExpiry.java


注:本文中的javax.cache.expiry.Duration.isEternal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。