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

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

本文整理了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

  1. /**
  2. * Returns the size (in bytes) that this EhCache is using in memory (RAM), or <code>-1</code> if that
  3. * number is unknown or cannot be calculated.
  4. *
  5. * @return the size (in bytes) that this EhCache is using in memory (RAM), or <code>-1</code> if that
  6. * number is unknown or cannot be calculated.
  7. */
  8. public long getMemoryUsage() {
  9. try {
  10. return cache.calculateInMemorySize();
  11. }
  12. catch (Throwable t) {
  13. return -1;
  14. }
  15. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Deprecated public long calculateInMemorySize() throws IllegalStateException, CacheException {
  5. return underlyingCache.calculateInMemorySize();
  6. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Deprecated public long calculateInMemorySize() throws IllegalStateException, CacheException {
  5. // THIS IS GENERATED CODE -- DO NOT HAND MODIFY!
  6. Thread t = Thread.currentThread();
  7. ClassLoader prev = t.getContextClassLoader();
  8. t.setContextClassLoader(this.classLoader);
  9. try {
  10. return this.cache.calculateInMemorySize();
  11. } finally {
  12. t.setContextClassLoader(prev);
  13. }
  14. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public long calculateInMemorySize() throws IllegalStateException, CacheException {
  5. return underlyingCache.calculateInMemorySize();
  6. }

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

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

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

  1. /**
  2. * Returns the size (in bytes) that this EhCache is using in memory (RAM), or <code>-1</code> if that
  3. * number is unknown or cannot be calculated.
  4. *
  5. * @return the size (in bytes) that this EhCache is using in memory (RAM), or <code>-1</code> if that
  6. * number is unknown or cannot be calculated.
  7. */
  8. public long getMemoryUsage() {
  9. try {
  10. return cache.calculateInMemorySize();
  11. }
  12. catch (Throwable t) {
  13. return -1;
  14. }
  15. }

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

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

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Deprecated public long calculateInMemorySize() throws IllegalStateException, CacheException {
  5. return underlyingCache.calculateInMemorySize();
  6. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public long getLocalHeapSizeInBytes() {
  5. if (!statisticsEnabled.get()) {
  6. return 0;
  7. }
  8. return cache.calculateInMemorySize();
  9. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Deprecated public long calculateInMemorySize() throws IllegalStateException, CacheException {
  5. return underlyingCache.calculateInMemorySize();
  6. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public long calculateInMemorySize() throws IllegalStateException, CacheException {
  5. // THIS IS GENERATED CODE -- DO NOT HAND MODIFY!
  6. Thread t = Thread.currentThread();
  7. ClassLoader prev = t.getContextClassLoader();
  8. t.setContextClassLoader(this.classLoader);
  9. try {
  10. return this.cache.calculateInMemorySize();
  11. } finally {
  12. t.setContextClassLoader(prev);
  13. }
  14. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Deprecated public long calculateInMemorySize() throws IllegalStateException, CacheException {
  5. // THIS IS GENERATED CODE -- DO NOT HAND MODIFY!
  6. Thread t = Thread.currentThread();
  7. ClassLoader prev = t.getContextClassLoader();
  8. t.setContextClassLoader(this.classLoader);
  9. try {
  10. return this.cache.calculateInMemorySize();
  11. } finally {
  12. t.setContextClassLoader(prev);
  13. }
  14. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Deprecated public long calculateInMemorySize() throws IllegalStateException, CacheException {
  5. // THIS IS GENERATED CODE -- DO NOT HAND MODIFY!
  6. Thread t = Thread.currentThread();
  7. ClassLoader prev = t.getContextClassLoader();
  8. t.setContextClassLoader(this.classLoader);
  9. try {
  10. return this.cache.calculateInMemorySize();
  11. } finally {
  12. t.setContextClassLoader(prev);
  13. }
  14. }

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

  1. public long calculateInMemorySize() throws IllegalStateException,
  2. CacheException {
  3. return self().calculateInMemorySize();
  4. }

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

  1. public long calculateInMemorySize() throws IllegalStateException,
  2. CacheException {
  3. return self().calculateInMemorySize();
  4. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public long getSizeInMemory() {
  5. try {
  6. return cache.calculateInMemorySize();
  7. } catch (Throwable t) {
  8. if (t instanceof NonStopCacheException) {
  9. HibernateNonstopCacheExceptionHandler.getInstance().handleNonstopCacheException((NonStopCacheException) t);
  10. }
  11. return -1;
  12. }
  13. }

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

  1. /**
  2. * Check whether a new "in memory" size sample need to be re-calculated.
  3. *
  4. * @param cache The cache.
  5. * @return <code>true</code> if a new sample was recalculated;
  6. * <code>false</code> otherwise.
  7. */
  8. public boolean checkInMemorySample(Ehcache cache) {
  9. Sample sample = this.inMemorySamples.get(cache.getName());
  10. int elements = cache.getSize();
  11. if (sample == null || sample.elements() * RESAMPLE_FACTOR < elements || sample._bytesize == 0) {
  12. long bytesize = elements > 0? cache.calculateInMemorySize() : 0;
  13. sample = new Sample(elements, bytesize);
  14. this.inMemorySamples.put(cache.getName(), sample);
  15. return elements > 0;
  16. }
  17. return false;
  18. }

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

  1. @RestMethod(required = { PARAM_CACHE })
  2. public void getCacheElementMemorySize(RestRequest request,
  3. RestResponse response) throws IOException {
  4. String cacheName = request.getParameter(PARAM_CACHE);
  5. Ehcache cache = cacheManager.getEhcache(cacheName);
  6. if (cache != null) {
  7. response.value(cache.calculateInMemorySize());
  8. }
  9. }

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

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

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

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

相关文章

Ehcache类方法