本文整理匯總了Java中javax.cache.expiry.Duration.isZero方法的典型用法代碼示例。如果您正苦於以下問題:Java Duration.isZero方法的具體用法?Java Duration.isZero怎麽用?Java Duration.isZero使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.cache.expiry.Duration
的用法示例。
在下文中一共展示了Duration.isZero方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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());
}
示例2: 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());
}
示例3: 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());
}
示例4: 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)");
}
}
}
示例5: 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);
}