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

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

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

Ehcache.getSize介绍

[英]Gets the size of the cache. This is a subtle concept. See below.

The size is the number of net.sf.ehcache.Elements in the net.sf.ehcache.store.MemoryStore plus the number of net.sf.ehcache.Elements in the net.sf.ehcache.store.disk.DiskStore.

This number is the actual number of elements, including expired elements that have not been removed.

Expired elements are removed from the the memory store when getting an expired element, or when attempting to spool an expired element to disk.

Expired elements are removed from the disk store when getting an expired element, or when the expiry thread runs, which is once every five minutes.

To get an exact size, which would exclude expired elements, use #getKeysWithExpiryCheck().size(), although see that method for the approximate time that would take.

To get a very fast result, use #getKeysNoDuplicateCheck().size(). If the disk store is being used, there will be some duplicates.

Note:getSize() is a very expensive operation in off-heap, disk and Terracotta implementations.
[中]获取缓存的大小。这是一个微妙的概念。见下文。
大小是网络的数量。旧金山。ehcache。网络中的元素。旧金山。ehcache。百货商店MemoryStore加上净存储的数量。旧金山。ehcache。网络中的元素。旧金山。ehcache。百货商店磁盘磁盘库。
此数字是元素的实际数量,包括尚未删除的过期元素。
获取过期元素或尝试将过期元素假脱机到磁盘时,将从内存存储中删除过期元素。
获取过期元素时,或当过期线程运行时(每五分钟一次),会从磁盘存储中删除过期元素。
要获得排除过期元素的确切大小,请使用#getKeysWithExpiryCheck()。size(),但请参阅该方法以了解所需的大致时间。
要获得非常快速的结果,请使用#GetKeysNodeUpplicateCheck()。大小()。如果正在使用磁盘存储,则会有一些重复项。
注意:getSize()在堆外、磁盘和Terracotta实现中是一个非常昂贵的操作。

代码示例

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

public int size() {
  try {
    return cache.getSize();
  } catch (Throwable t) {
    throw new CacheException(t);
  }
}

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

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

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

/**
* {@inheritDoc}
*/
public int getSize() 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.getSize();
  } finally {
    t.setContextClassLoader(prev);
  }
}

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

/**
 * @return the number of elements in ehcache's MemoryStore
 */
public final long getElementCountInMemory() {
  try {
    return cache.getSize();
  } catch (net.sf.ehcache.CacheException ce) {
    throw new CacheException(ce);
  }
}

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

/**
 * {@inheritDoc}
 */
public long getElementCountInMemory() {
  try {
    return cache.getSize();
  } catch (net.sf.ehcache.CacheException ce) {
    if (ce instanceof NonStopCacheException) {
      HibernateNonstopCacheExceptionHandler.getInstance().handleNonstopCacheException((NonStopCacheException) ce);
      return -1;
    } else {
      throw new CacheException(ce);
    }
  }
}

代码示例来源:origin: io.github.hengyunabc/mybatis-ehcache-spring

/**
 * {@inheritDoc}
 */
public int getSize() {
 return cache.getSize();
}

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

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

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

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

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

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

代码示例来源:origin: org.mybatis.caches/mybatis-ehcache

/**
 * {@inheritDoc}
 */
@Override
public int getSize() {
  return cache.getSize();
}

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

@Override
public boolean isEmpty() {
  return this.cache.getSize() > 0;
}

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

/**
 * @return the number of elements in ehcache's MemoryStore
 */
public final long getElementCountInMemory() {
  try {
    return cache.getSize();
  } catch (net.sf.ehcache.CacheException ce) {
    throw new CacheException(ce);
  }
}

代码示例来源:origin: org.apache.cxf.services.sts/cxf-services-sts-core

@ManagedOperation()
@Override
public int size() {
  return cache.getSize();
}

代码示例来源:origin: org.apache.shiro/shiro-ehcache

public int size() {
  try {
    return cache.getSize();
  } catch (Throwable t) {
    throw new CacheException(t);
  }
}

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

@ManagedOperation()
@Override
public int size() {
  return cache.getSize();
}

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

@Override
public long deleteAll() {
  return ticketCatalog.findAll().stream()
    .map(this::getTicketCacheFor)
    .filter(Objects::nonNull)
    .mapToLong(instance -> {
      val size = instance.getSize();
      instance.removeAll();
      return size;
    }).sum();
}

代码示例来源:origin: huangjian888/jeeweb-mybatis-springboot

@Override
public int size() {
  if (springCache.getNativeCache() instanceof Ehcache) {
    Ehcache ehcache = (Ehcache) springCache.getNativeCache();
    return ehcache.getSize();
  }
  throw new UnsupportedOperationException("invoke spring cache abstract size method not supported");
}

代码示例来源:origin: cn.jeeweb/jeeweb-common-security

@Override
public int size() {
  if (springCache.getNativeCache() instanceof Ehcache) {
    Ehcache ehcache = (Ehcache) springCache.getNativeCache();
    return ehcache.getSize();
  }
  throw new UnsupportedOperationException("invoke spring cache abstract size method not supported");
}

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

/**
 * {@inheritDoc}
 */
public int getSize() {
  try {
    return this.getCache().getSize();
  } catch (Throwable t) {
    throw new CacheException(t);
  }
}

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

@RestMethod(required = { PARAM_CACHE })
public void getCacheElementCount(RestRequest request, RestResponse response)
    throws IOException {
  String cacheName = request.getParameter(PARAM_CACHE);
  Ehcache cache = cacheManager.getEhcache(cacheName);
  if (cache != null) {
    response.value(cache.getSize());
  }
}

相关文章

微信公众号

最新文章

更多

Ehcache类方法