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

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

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

Cache.getKeysWithExpiryCheck介绍

[英]Returns a list of all element keys 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.

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 #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.

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.
[中]返回缓存中所有元素键的列表。只返回未过期元素的键。
返回的密钥是唯一的,可以视为一组。
返回的列表不是活动列表。这是一份副本。
所花费的时间是O(n),其中n是缓存中的元素数。在1.8Ghz P4上,每1000个条目所需的时间约为200ms。此方法不同步,因为它依赖于从#getKeys()返回的非活动列表,该列表是同步的,每1000个条目需要8毫秒。这样,即使该方法返回速度非常慢,也可以保持缓存的活跃度。
考虑您的使用是否需要检查过期的密钥。由于此方法需要很长时间,具体取决于缓存设置,因此在获取列表时,该列表可能已经过时。

代码示例

代码示例来源:origin: org.apache.fulcrum/fulcrum-cache

/**
 * @see org.apache.fulcrum.cache.GlobalCacheService#getKeys()
 */
public List getKeys()
{
  return this.cache.getKeysWithExpiryCheck();
}

代码示例来源:origin: actiontech/dble

@Override
public CacheStatic getCacheStatic() {
  cacheStatistics.setItemSize(enCache.getKeysWithExpiryCheck().size());
  return cacheStatistics;
}

代码示例来源:origin: org.jasig.cas/cas-server-integration-ehcache

@Override
  public int serviceTicketCount() {
    return BooleanUtils.toInteger(this.supportRegistryState, this.serviceTicketsCache.getKeysWithExpiryCheck()
        .size(), super.serviceTicketCount());
  }
}

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

/**
 * {@inheritDoc}
 */
public int getSizeBasedOnAccuracy(int statisticsAccuracy)
    throws IllegalStateException, CacheException {
  if (statisticsAccuracy == Statistics.STATISTICS_ACCURACY_BEST_EFFORT) {
    return getSize();
  } else if (statisticsAccuracy == Statistics.STATISTICS_ACCURACY_GUARANTEED) {
    return getKeysWithExpiryCheck().size();
  } else if (statisticsAccuracy == Statistics.STATISTICS_ACCURACY_NONE) {
    return getKeysNoDuplicateCheck().size();
  }
  throw new IllegalArgumentException("Unknown statistics accuracy: "
      + statisticsAccuracy);
}

代码示例来源:origin: org.jasig.cas/cas-server-integration-ehcache

@Override
public int sessionCount() {
  return BooleanUtils.toInteger(this.supportRegistryState, this.ticketGrantingTicketsCache
      .getKeysWithExpiryCheck().size(), super.sessionCount());
}

代码示例来源:origin: org.jasig.cas/cas-server-integration-ehcache

@Override
public Collection<Ticket> getTickets() {
  final Collection<Element> serviceTickets = this.serviceTicketsCache.getAll(
      this.serviceTicketsCache.getKeysWithExpiryCheck()).values();
  final Collection<Element> tgtTicketsTickets = this.ticketGrantingTicketsCache.getAll(
      this.ticketGrantingTicketsCache.getKeysWithExpiryCheck()).values();
  final Collection<Ticket> allTickets = new HashSet<>(serviceTickets.size() + tgtTicketsTickets.size());
  for (final Element ticket : serviceTickets) {
    final Ticket proxiedTicket = getProxiedTicketInstance((Ticket) ticket.getObjectValue());
    allTickets.add(proxiedTicket);
  }
  for (final Element ticket : tgtTicketsTickets) {
    final Ticket proxiedTicket = getProxiedTicketInstance((Ticket) ticket.getObjectValue());
    allTickets.add(proxiedTicket);
  }
  return decodeTickets(allTickets);
}

代码示例来源:origin: ww20081120/framework

/**
 * Description: <br>
 * 
 * @author 王伟<br>
 * @taskId <br>
 * @param nodeName
 * @param type
 * @return <br>
 */
@SuppressWarnings("unchecked")
@Override
public <T> Map<String, T> getNode(String nodeName, Class<T> type) {
  Cache cache = getCache(nodeName);
  List<String> keys = cache.getKeysWithExpiryCheck();
  Map<String, T> cacheMap = new HashMap<String, T>();
  if (CollectionUtils.isNotEmpty(keys)) {
    for (String key : keys) {
      Element element = cache.get(key);
      Object value = (element != null ? element.getObjectValue() : null);
      if (value != null && type != null && !type.isInstance(value)) {
        throw new IllegalStateException(
          "Cached value is not of required type [" + type.getName() + "]: " + value);
      }
      cacheMap.put(key, (T) value);
    }
  }
  return cacheMap;
}

代码示例来源:origin: org.apache.jspwiki/jspwiki-main

List<String> keys = m_attCache.getKeysWithExpiryCheck();
all = new ArrayList<>();
for (String key : keys) {

代码示例来源:origin: org.apache.jspwiki/jspwiki-main

List<String> keys = m_cache.getKeysWithExpiryCheck();
all = new TreeSet<WikiPage>();
for (String key : keys) {

代码示例来源:origin: org.jasig.portal/uPortal-portlets

if (!cssSkinFailureCache.getKeysWithExpiryCheck().contains(cssInstanceKey)) {
  createLessIncludeFile(data);
  processLessFile(data);

代码示例来源:origin: org.apache.jspwiki/jspwiki-main

/**
 * {@inheritDoc}
 */
@Override
public void moveAttachmentsForPage( String oldParent, String newParent ) throws ProviderException
{
  m_provider.moveAttachmentsForPage(oldParent, newParent);
  m_cache.remove(newParent);
  m_cache.remove(oldParent);
  //
  //  This is a kludge to make sure that the pages are removed
  //  from the other cache as well.
  //
  String checkName = oldParent + "/";
  @SuppressWarnings("unchecked")
  List< String > names = m_cache.getKeysWithExpiryCheck();
  for( String name : names )
  {
    if( name.startsWith( checkName ) )
    {
      m_attCache.remove(name);
    }
  }
}

相关文章

微信公众号

最新文章

更多

Cache类方法