net.sf.ehcache.Cache.isExpired()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(204)

本文整理了Java中net.sf.ehcache.Cache.isExpired()方法的一些代码示例,展示了Cache.isExpired()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.isExpired()方法的具体详情如下:
包路径:net.sf.ehcache.Cache
类名称:Cache
方法名:isExpired

Cache.isExpired介绍

[英]Checks whether this cache element has expired.

The element is expired if:

  1. the idle time is non-zero and has elapsed, unless the cache is eternal; or
  2. the time to live is non-zero and has elapsed, unless the cache is eternal; or
  3. the value of the element is null.
    [中]检查此缓存元素是否已过期。
    如果出现以下情况,元素将过期:
    1.空闲时间非零且已过,除非缓存是永久的;或
    1.生存时间非零且已过,除非缓存是永恒的;或
    1.元素的值为空。

代码示例

代码示例来源:origin: net.sf.ehcache/ehcache

Element element = entry.getValue();
if (element != null) {
  if (isExpired(element)) {
    tryRemoveImmediately(key, true);
    expired.add(key);

代码示例来源:origin: net.sf.ehcache/ehcache

/**
 * Gets an element from the cache, without updating Element statistics. Cache statistics are
 * not updated.
 * <p>
 * Listeners are not called.
 *
 * @param key a serializable value
 * @return the element, or null, if it does not exist.
 * @throws IllegalStateException if the cache is not {@link Status#STATUS_ALIVE}
 * @see #isExpired
 * @since 1.2
 */
public final Element getQuiet(Object key) throws IllegalStateException, CacheException {
  checkStatus();
  Element element = compoundStore.getQuiet(key);
  if (element == null) {
    return null;
  } else if (isExpired(element)) {
    tryRemoveImmediately(key, false);
    return null;
  } else {
    return element;
  }
}

代码示例来源:origin: net.sf.ehcache/ehcache

getObserver.end(GetOutcome.MISS_NOT_FOUND);
  return null;
} else if (isExpired(element)) {
  tryRemoveImmediately(key, true);
  getObserver.end(GetOutcome.MISS_EXPIRED);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

private Element elementStatsHelper(Object key, boolean quiet, boolean notifyListeners, Element element) {
  if (element != null) {
    if (isExpired(element)) {
      tryRemoveImmediately(key, notifyListeners);
      element = null;
    } else if (!(quiet || skipUpdateAccessStatistics(element))) {
      element.updateAccessStatistics();
    }
  }
  return element;
}

代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache

Element element = entry.getValue();
if (element != null) {
  if (isExpired(element)) {
    tryRemoveImmediately(key, true);
    expired.add(key);

代码示例来源:origin: net.sf.ehcache.internal/ehcache-core

Element element = entry.getValue();
if (element != null) {
  if (isExpired(element)) {
    tryRemoveImmediately(key, true);
    expired.add(key);

代码示例来源:origin: net.sf.ehcache.internal/ehcache-core

/**
 * Gets an element from the cache, without updating Element statistics. Cache statistics are
 * not updated.
 * <p>
 * Listeners are not called.
 *
 * @param key a serializable value
 * @return the element, or null, if it does not exist.
 * @throws IllegalStateException if the cache is not {@link Status#STATUS_ALIVE}
 * @see #isExpired
 * @since 1.2
 */
public final Element getQuiet(Object key) throws IllegalStateException, CacheException {
  checkStatus();
  Element element = compoundStore.getQuiet(key);
  if (element == null) {
    return null;
  } else if (isExpired(element)) {
    tryRemoveImmediately(key, false);
    return null;
  } else {
    return element;
  }
}

代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache

/**
 * Gets an element from the cache, without updating Element statistics. Cache statistics are
 * not updated.
 * <p/>
 * Listeners are not called.
 *
 * @param key a serializable value
 * @return the element, or null, if it does not exist.
 * @throws IllegalStateException if the cache is not {@link Status#STATUS_ALIVE}
 * @see #isExpired
 * @since 1.2
 */
public final Element getQuiet(Object key) throws IllegalStateException, CacheException {
  checkStatus();
  Element element = compoundStore.getQuiet(key);
  if (element == null) {
    return null;
  } else if (isExpired(element)) {
    tryRemoveImmediately(key, false);
    return null;
  } else {
    return element;
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

Element element = entry.getValue();
if (element != null) {
  if (isExpired(element)) {
    if (LOG.isDebugEnabled()) {
      LOG.debug(configuration.getName() + " cache hit, but element expired");

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

if (isExpired(element)) {
  if (LOG.isDebugEnabled()) {
    LOG.debug(configuration.getName() + " cache hit, but element expired");

代码示例来源:origin: net.sf.ehcache.internal/ehcache-core

getObserver.end(GetOutcome.MISS_NOT_FOUND);
  return null;
} else if (isExpired(element)) {
  tryRemoveImmediately(key, true);
  getObserver.end(GetOutcome.MISS_EXPIRED);

代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache

getObserver.end(GetOutcome.MISS_NOT_FOUND);
  return null;
} else if (isExpired(element)) {
  tryRemoveImmediately(key, true);
  getObserver.end(GetOutcome.MISS_EXPIRED);

相关文章

Cache类方法