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

x33g5p2x  于2022-01-19 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(181)

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

Ehcache.getKeysWithExpiryCheck介绍

[英]Returns a list of all elements in the cache. Only keys of non-expired elements are returned.

The returned keys are unique and can be considered a set.

The List returned is not live. It is a copy.

For large caches - or caches with high-latency storage this method can take a very long time to complete. You should seriously consider whether your usage requires checking for expired keys before choosing to call this method. As this method can take a long time the results may also be significantly out of date by the time the method returns.
[中]返回缓存中所有元素的列表。只返回未过期元素的键。
返回的密钥是唯一的,可以视为一组。
返回的列表不是活动列表。这是一份副本。
对于大型缓存或具有高延迟存储的缓存,此方法可能需要非常长的时间才能完成。在选择调用这个方法之前,您应该认真考虑您的使用是否需要检查过期的密钥。由于此方法可能需要很长时间,因此当该方法返回时,结果也可能明显过时。

代码示例

代码示例来源:origin: kaaproject/kaa

@Override
public List<SdkKey> getCachedSdkKeys(String applicationId) {
 List<SdkKey> keys = new ArrayList<>();
 Ehcache cache = (Ehcache) adminCacheManager.getCache(SDK_CACHE).getNativeCache();
 List<?> cachedKeys = cache.getKeysWithExpiryCheck();
 for (Object cachedKey : cachedKeys) {
  if (cachedKey instanceof SdkKey) {
   SdkKey cachedSdkKey = (SdkKey) cachedKey;
   if (applicationId.equals(cachedSdkKey.getSdkProfile().getApplicationId())) {
    keys.add(cachedSdkKey);
   }
  }
 }
 return keys;
}

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

/**
 * {@inheritDoc}
 */
public List getKeysWithExpiryCheck() throws IllegalStateException, CacheException {
  return underlyingCache.getKeysWithExpiryCheck();
}

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

/**
* {@inheritDoc}
*/
public List getKeysWithExpiryCheck() throws IllegalStateException, CacheException {
  // THIS IS GENERATED CODE -- DO NOT HAND MODIFY!
  Thread t = Thread.currentThread();
  ClassLoader prev = t.getContextClassLoader();
  t.setContextClassLoader(this.classLoader);
  try {
    return this.cache.getKeysWithExpiryCheck();
  } finally {
    t.setContextClassLoader(prev);
  }
}

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

/**
 * {@inheritDoc}
 */
public List getKeysWithExpiryCheck() throws IllegalStateException, CacheException {
  return underlyingCache.getKeysWithExpiryCheck();
}

代码示例来源:origin: apache/cxf

@SuppressWarnings("unchecked")
public Collection<String> getTokenIdentifiers() {
  if (cache == null) {
    return null;
  }
  return cache.getKeysWithExpiryCheck();
}

代码示例来源:origin: org.apache.cxf/cxf-rt-ws-security

@SuppressWarnings("unchecked")
public Collection<String> getTokenIdentifiers() {
  if (cache == null) {
    return null;
  }
  return cache.getKeysWithExpiryCheck();
}

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

/**
 * {@inheritDoc}
 */
public List getKeysWithExpiryCheck() throws IllegalStateException, CacheException {
  return underlyingCache.getKeysWithExpiryCheck();
}

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

/**
 * {@inheritDoc}
 */
public List getKeysWithExpiryCheck() throws IllegalStateException, CacheException {
  return underlyingCache.getKeysWithExpiryCheck();
}

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

/**
 * Returns a list of all elements in the cache. Only keys of non-expired elements are returned.
 * <p/>
 * The returned keys are unique and can be considered a set.
 * <p/>
 * The List returned is not live. It is a copy.
 * <p/>
 * The time taken is O(n), where n is the number of elements in the cache. On a 1.8Ghz P4, the time taken is approximately 200ms per
 * 1000 entries. This method is not synchronized, because it relies on a non-live list returned from {@link #getKeys()} , which is
 * synchronised, and which takes 8ms per 1000 entries. This way cache liveness is preserved, even if this method is very slow to return.
 * <p/>
 * Consider whether your usage requires checking for expired keys. Because this method takes so long, depending on cache settings, the
 * list could be quite out of date by the time you get it.
 * 
 * @return a list of {@link Object} keys
 * @throws IllegalStateException
 *             if the cache is not {@link net.sf.ehcache.Status#STATUS_ALIVE}
 */
public List getKeysWithExpiryCheck() throws IllegalStateException, CacheException {
  return cache.getKeysWithExpiryCheck();
}

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

/**
* {@inheritDoc}
*/
public List getKeysWithExpiryCheck() throws IllegalStateException, CacheException {
  // THIS IS GENERATED CODE -- DO NOT HAND MODIFY!
  Thread t = Thread.currentThread();
  ClassLoader prev = t.getContextClassLoader();
  t.setContextClassLoader(this.classLoader);
  try {
    return this.cache.getKeysWithExpiryCheck();
  } finally {
    t.setContextClassLoader(prev);
  }
}

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

/**
* {@inheritDoc}
*/
public List getKeysWithExpiryCheck() throws IllegalStateException, CacheException {
  // THIS IS GENERATED CODE -- DO NOT HAND MODIFY!
  Thread t = Thread.currentThread();
  ClassLoader prev = t.getContextClassLoader();
  t.setContextClassLoader(this.classLoader);
  try {
    return this.cache.getKeysWithExpiryCheck();
  } finally {
    t.setContextClassLoader(prev);
  }
}

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

/**
* {@inheritDoc}
*/
public List getKeysWithExpiryCheck() throws IllegalStateException, CacheException {
  // THIS IS GENERATED CODE -- DO NOT HAND MODIFY!
  Thread t = Thread.currentThread();
  ClassLoader prev = t.getContextClassLoader();
  t.setContextClassLoader(this.classLoader);
  try {
    return this.cache.getKeysWithExpiryCheck();
  } finally {
    t.setContextClassLoader(prev);
  }
}

代码示例来源:origin: rtyley/mini-git-server

@SuppressWarnings("unchecked")
public List getKeysWithExpiryCheck() throws IllegalStateException,
  CacheException {
 return self().getKeysWithExpiryCheck();
}

代码示例来源:origin: org.apereo.cas/cas-server-support-ehcache-ticket-registry

private static Map<Object, Element> getAllExpired(final Ehcache map) {
    try {
      return map.getAll(map.getKeysWithExpiryCheck());
    } catch (final Exception e) {
      LOGGER.warn(e.getMessage(), e);
      return new HashMap<>(0);
    }
  }
}

代码示例来源:origin: com.madgag/mini-git-server-server

@SuppressWarnings("unchecked")
public List getKeysWithExpiryCheck() throws IllegalStateException,
  CacheException {
 return self().getKeysWithExpiryCheck();
}

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

void logCacheState(String operator) {
  if (cacheDebug) {
    String name = m_callCache.getName();
    net.sf.ehcache.Ehcache ehcache = m_callCache.unwrap(Ehcache.class); // DEBUGGING ONLY
    StringBuilder entriesSB = new StringBuilder();
    List keys = ehcache.getKeysWithExpiryCheck(); // only current keys
    entriesSB.append("   * keys(").append(keys.size()).append("):").append(new ArrayList<Object>(keys)).append("\n");
    Collection<Element> entries = ehcache.getAll(keys).values();
    int countMaps = 0;
    for (Element element : entries) {
      if (element == null) continue;
      int count = 0;
      countMaps += count;
      if (cacheDebugDetailed) {
        entriesSB.append("   ").append(element.getObjectKey()).append(" => (").append(count).append(")").append(element.getObjectValue()).append("\n");
      }
    }
    log.info("SScache:"+name+":: "+operator+" ::\n  entries(Ehcache[key => payload],"+keys.size()+" + "+countMaps+" = "+(keys.size()+countMaps)+"):\n"+entriesSB);
  }
}

代码示例来源:origin: org.terracotta/ehcache-probe

@RestMethod(required = { PARAM_CACHE, PARAM_COUNT }, optional = { PARAM_QUERY })
public void getCacheKeys(RestRequest request, RestResponse response)
    throws IOException {
  String cacheName = request.getParameter(PARAM_CACHE);
  String countString = request.getParameter(PARAM_COUNT);
  String query = request.getParameter(PARAM_QUERY);
  int count = Integer.parseInt(countString);
  if (count <= 0) {
    throw new IllegalArgumentException("count needs to be positive");
  }
  Ehcache cache = cacheManager.getEhcache(cacheName);
  response.childType(ELEMENT_KEY);
  if (cache != null) {
    List keys = cache.getKeysWithExpiryCheck();
    Iterator it = keys.iterator();
    while (count > 0 && it.hasNext()) {
      Object key = it.next();
      if (null == query || queryKey(key, query)) {
        count--;
        response.child(key);
      }
    }
  }
}

代码示例来源:origin: org.terracotta/ehcache-probe

@RestMethod(required = { PARAM_CACHE, PARAM_QUERY })
public void removeQueryFromCache(RestRequest request, RestResponse response)
    throws IOException {
  String cacheName = request.getParameter(PARAM_CACHE);
  String query = request.getParameter(PARAM_QUERY);
  int count = 0;
  Ehcache cache = cacheManager.getEhcache(cacheName);
  if (cache != null) {
    List<Object> keys = cache.getKeysWithExpiryCheck();
    for (Object key : keys) {
      if (queryKey(key, query)) {
        if (cache.removeQuiet(key)) {
          count++;
        }
      }
    }
    response.value(count);
  }
}

相关文章

Ehcache类方法