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

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

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

Ehcache.calculateInMemorySize介绍

[英]Gets the size of the memory store for this cache

Warning: This method can be very expensive to run. Allow approximately 1 second per 1MB of entries. Running this method could create liveness problems because the object lock is held for a long period
[中]获取此缓存的内存存储的大小
警告:运行此方法可能非常昂贵。每1MB条目允许大约1秒。运行此方法可能会产生活动性问题,因为对象锁被保持很长时间

代码示例

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

/**
 * Returns the size (in bytes) that this EhCache is using in memory (RAM), or <code>-1</code> if that
 * number is unknown or cannot be calculated.
 *
 * @return the size (in bytes) that this EhCache is using in memory (RAM), or <code>-1</code> if that
 *         number is unknown or cannot be calculated.
 */
public long getMemoryUsage() {
  try {
    return cache.calculateInMemorySize();
  }
  catch (Throwable t) {
    return -1;
  }
}

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

/**
 * {@inheritDoc}
 */
@Deprecated public long calculateInMemorySize() throws IllegalStateException, CacheException {
  return underlyingCache.calculateInMemorySize();
}

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

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

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

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

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

/**
 * Gets the size of the memory store for this cache
 * <p/>
 * Warning: This method can be very expensive to run. Allow approximately 1 second per 1MB of entries. Running this method could create
 * liveness problems because the object lock is held for a long period
 * <p/>
 * 
 * @return the approximate size of the memory store in bytes
 * @throws IllegalStateException
 */
public long calculateInMemorySize() throws IllegalStateException, CacheException {
  return cache.calculateInMemorySize();
}

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

/**
 * Returns the size (in bytes) that this EhCache is using in memory (RAM), or <code>-1</code> if that
 * number is unknown or cannot be calculated.
 *
 * @return the size (in bytes) that this EhCache is using in memory (RAM), or <code>-1</code> if that
 *         number is unknown or cannot be calculated.
 */
public long getMemoryUsage() {
  try {
    return cache.calculateInMemorySize();
  }
  catch (Throwable t) {
    return -1;
  }
}

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

/**
 * Warning: This method can be very expensive to run. Allow approximately 1 second
 * per 1MB of entries. Running this method could create liveness problems
 * because the object lock is held for a long period
 * <p/>
 *
 * @return the approximate size of memory ehcache is using for the MemoryStore for this cache
 */
public final long getSizeInMemory() {
  try {
    return cache.calculateInMemorySize();
  } catch (Throwable t) {
    return -1;
  }
}

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

/**
 * {@inheritDoc}
 */
@Deprecated public long calculateInMemorySize() throws IllegalStateException, CacheException {
  return underlyingCache.calculateInMemorySize();
}

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

/**
 * {@inheritDoc}
 */
public long getLocalHeapSizeInBytes() {
  if (!statisticsEnabled.get()) {
    return 0;
  }
  return cache.calculateInMemorySize();
}

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

/**
 * {@inheritDoc}
 */
@Deprecated public long calculateInMemorySize() throws IllegalStateException, CacheException {
  return underlyingCache.calculateInMemorySize();
}

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

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

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

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

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

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

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

public long calculateInMemorySize() throws IllegalStateException,
  CacheException {
 return self().calculateInMemorySize();
}

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

public long calculateInMemorySize() throws IllegalStateException,
  CacheException {
 return self().calculateInMemorySize();
}

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

/**
 * {@inheritDoc}
 */
public long getSizeInMemory() {
  try {
    return cache.calculateInMemorySize();
  } catch (Throwable t) {
    if (t instanceof NonStopCacheException) {
      HibernateNonstopCacheExceptionHandler.getInstance().handleNonstopCacheException((NonStopCacheException) t);
    }
    return -1;
  }
}

代码示例来源:origin: org.pageseeder.bastille/pso-bastille

/**
 * Check whether a new "in memory" size sample need to be re-calculated.
 *
 * @param cache The cache.
 * @return <code>true</code> if a new sample was recalculated;
 *         <code>false</code> otherwise.
 */
public boolean checkInMemorySample(Ehcache cache) {
 Sample sample = this.inMemorySamples.get(cache.getName());
 int elements = cache.getSize();
 if (sample == null || sample.elements() * RESAMPLE_FACTOR < elements || sample._bytesize == 0) {
  long bytesize = elements > 0? cache.calculateInMemorySize() : 0;
  sample = new Sample(elements, bytesize);
  this.inMemorySamples.put(cache.getName(), sample);
  return elements > 0;
 }
 return false;
}

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

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

代码示例来源:origin: at.researchstudio.sat/won-core

logger.debug("Fetched and cached {} ", resource);
if (logger.isDebugEnabled()) {
  logger.debug("cache size: {} elements, in-memory size: {} bytes",cache.getSize(), cache.calculateInMemorySize());

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

return false;
} else {
  final long inMemorySizeInBytes = overflowToOffHeap ? cache.calculateOffHeapSize() : cache.calculateInMemorySize();
  final long avgSize = inMemorySizeInBytes
      / inMemoryCount;

相关文章

Ehcache类方法