本文整理匯總了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()));
}
}
示例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());
}
示例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());
}
示例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());
}
示例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() );
}
}
示例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)");
}
}
}
示例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);
}
示例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()));
}