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

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

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

/**
 * {@inheritDoc}
 */
public void evictExpiredElements() {
  underlyingCache.evictExpiredElements();
}

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

/**
* {@inheritDoc}
*/
public void evictExpiredElements() {
  // THIS IS GENERATED CODE -- DO NOT HAND MODIFY!
  Thread t = Thread.currentThread();
  ClassLoader prev = t.getContextClassLoader();
  t.setContextClassLoader(this.classLoader);
  try {
    this.cache.evictExpiredElements();
  } finally {
    t.setContextClassLoader(prev);
  }
}

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

/**
 * {@inheritDoc}
 */
public void evictExpiredElements() {
  underlyingCache.evictExpiredElements();
}

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

/**
 * {@inheritDoc}
 */
public void evictExpiredElements() {
  underlyingCache.evictExpiredElements();
}

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

/**
 * {@inheritDoc}
 */
public void evictExpiredElements() {
  underlyingCache.evictExpiredElements();
}

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

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

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

/**
* {@inheritDoc}
*/
public void evictExpiredElements() {
  // THIS IS GENERATED CODE -- DO NOT HAND MODIFY!
  Thread t = Thread.currentThread();
  ClassLoader prev = t.getContextClassLoader();
  t.setContextClassLoader(this.classLoader);
  try {
    this.cache.evictExpiredElements();
  } finally {
    t.setContextClassLoader(prev);
  }
}

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

/**
* {@inheritDoc}
*/
public void evictExpiredElements() {
  // THIS IS GENERATED CODE -- DO NOT HAND MODIFY!
  Thread t = Thread.currentThread();
  ClassLoader prev = t.getContextClassLoader();
  t.setContextClassLoader(this.classLoader);
  try {
    this.cache.evictExpiredElements();
  } finally {
    t.setContextClassLoader(prev);
  }
}

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

/**
* {@inheritDoc}
*/
public void evictExpiredElements() {
  // THIS IS GENERATED CODE -- DO NOT HAND MODIFY!
  Thread t = Thread.currentThread();
  ClassLoader prev = t.getContextClassLoader();
  t.setContextClassLoader(this.classLoader);
  try {
    this.cache.evictExpiredElements();
  } finally {
    t.setContextClassLoader(prev);
  }
}

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

public void evictExpiredElements() {
 self().evictExpiredElements();
}

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

public void evictExpiredElements() {
 self().evictExpiredElements();
}

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

@Override
public void evictExpiredMembers() {
  if (!getSecurityService().isSuperUser()) {
    throw new SecurityException("Only super admin can evict caches, current user not super admin");
  }
  if (this.cacheManager != null) {
    String[] allCacheNames = cacheManager.getCacheNames();
    for (String cacheName : allCacheNames) {
      Ehcache cache = cacheManager.getCache(cacheName);
      cache.evictExpiredElements();
    }
  }
}

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

@SuppressWarnings( "unchecked" )
public Collection<String> listKeysInCache()
{
  getEHCache().evictExpiredElements();
  List<String> keys = new ArrayList<String>();
  // this is going to be slow (if we have lots of items) but if you are concerned about speed you shouldn't call
  // this method anyway, this should only be used for information purposes
  String startsWithString = getKeyPrefix();
  for ( String key : (List<String>) getEHCache().getKeys() )
  {
    if ( key.startsWith( startsWithString ) )
    {
      keys.add( key.substring( startsWithString.length() ) );
    }
  }
  return keys;
}

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

@Override
public void run() {
  final long startTime = System.currentTimeMillis();
  
  final String[] cacheNames = this.cacheManager.getCacheNames();
  final Set<String> evictableCacheNames = this.calculateEvictableCacheNames(cacheNames);
  long evictedTotal = 0;
  for(String cacheName : evictableCacheNames) {
    Ehcache cache = this.cacheManager.getEhcache(cacheName);
    if(null != cache) {
      long preEvictSize = cache.getMemoryStoreSize();
      long evictStart = System.currentTimeMillis();
      cache.evictExpiredElements();
      if(logger.isDebugEnabled()) {
        long evicted = preEvictSize - cache.getMemoryStoreSize();
        evictedTotal += evicted;
        logger.debug("Evicted " + evicted + " elements from cache '" + cacheName + "' in " + (System.currentTimeMillis() - evictStart) + " ms");
      }
    } else {
      if(logger.isDebugEnabled()) {
        logger.debug("no cache found with name " + cacheName);
      }
    }
  }
  if(logger.isDebugEnabled()) {
    logger.debug("Evicted " + evictedTotal + " elements from " + evictableCacheNames.size() + " caches  in " + (System.currentTimeMillis() - startTime) + " ms");
  }
}

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

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

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

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

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

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

相关文章

Ehcache类方法