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

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

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

Ehcache.evictExpiredElements介绍

[英]Causes all elements stored in the Cache to be synchronously checked for expiry, and if expired, evicted.

For large caches - or caches with high-latency storage this method can take a very long time to complete. You should seriously consider relying on some form of capacity eviction to control cache capacity over calling this method. As this method can take a long time the cache may not be fully purged of expired elements on return, since more elements may have expired during the call.
[中]导致同步检查缓存中存储的所有元素是否过期,如果过期,则将其逐出。
对于大型缓存或具有高延迟存储的缓存,此方法可能需要非常长的时间才能完成。在调用此方法时,您应该认真考虑依赖某种形式的容量驱逐来控制缓存容量。由于此方法可能需要很长时间,缓存可能无法在返回时完全清除过期的元素,因为调用期间可能有更多的元素过期。

代码示例

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public void evictExpiredElements() {
  5. underlyingCache.evictExpiredElements();
  6. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public void evictExpiredElements() {
  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. this.cache.evictExpiredElements();
  11. } finally {
  12. t.setContextClassLoader(prev);
  13. }
  14. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public void evictExpiredElements() {
  5. underlyingCache.evictExpiredElements();
  6. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public void evictExpiredElements() {
  5. underlyingCache.evictExpiredElements();
  6. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public void evictExpiredElements() {
  5. underlyingCache.evictExpiredElements();
  6. }

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

  1. /**
  2. * Causes all elements stored in the Cache to be synchronously checked for expiry, and if expired, evicted.
  3. */
  4. public void evictExpiredElements() {
  5. cache.evictExpiredElements();
  6. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public void evictExpiredElements() {
  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. this.cache.evictExpiredElements();
  11. } finally {
  12. t.setContextClassLoader(prev);
  13. }
  14. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public void evictExpiredElements() {
  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. this.cache.evictExpiredElements();
  11. } finally {
  12. t.setContextClassLoader(prev);
  13. }
  14. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public void evictExpiredElements() {
  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. this.cache.evictExpiredElements();
  11. } finally {
  12. t.setContextClassLoader(prev);
  13. }
  14. }

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

  1. public void evictExpiredElements() {
  2. self().evictExpiredElements();
  3. }

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

  1. public void evictExpiredElements() {
  2. self().evictExpiredElements();
  3. }

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

  1. @Override
  2. public void evictExpiredMembers() {
  3. if (!getSecurityService().isSuperUser()) {
  4. throw new SecurityException("Only super admin can evict caches, current user not super admin");
  5. }
  6. if (this.cacheManager != null) {
  7. String[] allCacheNames = cacheManager.getCacheNames();
  8. for (String cacheName : allCacheNames) {
  9. Ehcache cache = cacheManager.getCache(cacheName);
  10. cache.evictExpiredElements();
  11. }
  12. }
  13. }

代码示例来源:origin: org.sonatype.nexus/nexus-proxy

  1. @SuppressWarnings( "unchecked" )
  2. public Collection<String> listKeysInCache()
  3. {
  4. getEHCache().evictExpiredElements();
  5. List<String> keys = new ArrayList<String>();
  6. // this is going to be slow (if we have lots of items) but if you are concerned about speed you shouldn't call
  7. // this method anyway, this should only be used for information purposes
  8. String startsWithString = getKeyPrefix();
  9. for ( String key : (List<String>) getEHCache().getKeys() )
  10. {
  11. if ( key.startsWith( startsWithString ) )
  12. {
  13. keys.add( key.substring( startsWithString.length() ) );
  14. }
  15. }
  16. return keys;
  17. }

代码示例来源:origin: com.googlecode.ehcache-spring-annotations/ehcache-spring-annotations

  1. @Override
  2. public void run() {
  3. final long startTime = System.currentTimeMillis();
  4. final String[] cacheNames = this.cacheManager.getCacheNames();
  5. final Set<String> evictableCacheNames = this.calculateEvictableCacheNames(cacheNames);
  6. long evictedTotal = 0;
  7. for(String cacheName : evictableCacheNames) {
  8. Ehcache cache = this.cacheManager.getEhcache(cacheName);
  9. if(null != cache) {
  10. long preEvictSize = cache.getMemoryStoreSize();
  11. long evictStart = System.currentTimeMillis();
  12. cache.evictExpiredElements();
  13. if(logger.isDebugEnabled()) {
  14. long evicted = preEvictSize - cache.getMemoryStoreSize();
  15. evictedTotal += evicted;
  16. logger.debug("Evicted " + evicted + " elements from cache '" + cacheName + "' in " + (System.currentTimeMillis() - evictStart) + " ms");
  17. }
  18. } else {
  19. if(logger.isDebugEnabled()) {
  20. logger.debug("no cache found with name " + cacheName);
  21. }
  22. }
  23. }
  24. if(logger.isDebugEnabled()) {
  25. logger.debug("Evicted " + evictedTotal + " elements from " + evictableCacheNames.size() + " caches in " + (System.currentTimeMillis() - startTime) + " ms");
  26. }
  27. }

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

  1. final long preEvictSize = cache.getMemoryStoreSize();
  2. final long evictStart = System.nanoTime();
  3. cache.evictExpiredElements();
  4. if (logger.isDebugEnabled()) {
  5. final long evicted = preEvictSize - cache.getMemoryStoreSize();

代码示例来源:origin: Jasig/uPortal

  1. final long preEvictSize = cache.getMemoryStoreSize();
  2. final long evictStart = System.nanoTime();
  3. cache.evictExpiredElements();
  4. if (logger.isDebugEnabled()) {
  5. final long evicted = preEvictSize - cache.getMemoryStoreSize();

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

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

相关文章

Ehcache类方法