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

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

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

Cache.getKeysNoDuplicateCheck介绍

[英]Returns a list of all elements in the cache, whether or not they are expired.

The returned keys are not unique and may contain duplicates. If the cache is only using the memory store, the list will be unique. If the disk store is being used as well, it will likely contain duplicates, because of the internal store design.

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

The time taken is O(log n). On a single CPU 1.8Ghz P4, approximately 6ms is required for 1000 entries and 36 for 50000.

This is the fastest getKeys method
[中]返回缓存中所有元素的列表,无论它们是否过期。
返回的密钥不是唯一的,可能包含重复项。如果缓存仅使用内存存储,则列表将是唯一的。如果磁盘存储也在使用中,由于内部存储设计的原因,它很可能包含重复项。
返回的列表不是活动列表。这是一份副本。
所用时间为O(对数n)。在单CPU 1.8Ghz P4上,1000个条目大约需要6ms,50000个条目大约需要36毫秒。
这是最快的getKeys方法

代码示例

代码示例来源:origin: dandelion/dandelion

@Override
  protected Collection<CacheEntry> doGetAll() {
   Collection<Element> elements = cache.getAll(cache.getKeysNoDuplicateCheck()).values();
   Collection<CacheEntry> cacheElements = new ArrayList<CacheEntry>();
   for (Element e : elements) {
     cacheElements.add((CacheEntry) e.getObjectValue());
   }
   return cacheElements;
  }
}

代码示例来源:origin: dandelion/dandelion

@Override
protected int doPut(String cacheKey, CacheEntry cacheElement) {
 cache.put(new Element(cacheKey, cacheElement));
 return cache.getKeysNoDuplicateCheck().size();
}

代码示例来源: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: fr.inria.eventcloud/eventcloud-core

@Override
public void removeEntriesFor(SubscriptionId subscriptionId) {
  @SuppressWarnings("unchecked")
  List<NotificationId> notificationIds =
      this.cache.getKeysNoDuplicateCheck();
  // TODO we should avoid to iterate all the keys
  for (NotificationId nid : notificationIds) {
    if (nid.isFor(subscriptionId)) {
      this.cache.remove(nid);
    }
  }
}

相关文章

Cache类方法