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

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

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

Ehcache.getCacheConfiguration介绍

[英]Gets the cache configuration this cache was created with.

Things like listeners that are added dynamically are excluded.
[中]获取创建此缓存时使用的缓存配置。
排除动态添加的侦听器之类的内容。

代码示例

代码示例来源:origin: gocd/gocd

public CacheConfiguration configuration() {
  return ehCache.getCacheConfiguration();
}

代码示例来源:origin: javamelody/javamelody

private int computeMemoryPercentUsed(Object cache) {
  final int maxElementsInMemory = ((Ehcache) cache).getCacheConfiguration()
      .getMaxElementsInMemory();
  if (maxElementsInMemory == 0) {
    // maxElementsInMemory peut être 0 (sans limite), cf issue 73
    return -1;
  }
  return (int) (100 * inMemoryObjectCount / maxElementsInMemory);
}

代码示例来源:origin: javamelody/javamelody

private String buildConfiguration(Object cache) {
  final StringBuilder sb = new StringBuilder();
  // getCacheConfiguration() et getMaxElementsOnDisk() n'existent pas en ehcache 1.2
  final CacheConfiguration config = ((Ehcache) cache).getCacheConfiguration();
  sb.append("ehcache [maxElementsInMemory = ").append(config.getMaxElementsInMemory());
  final boolean overflowToDisk = config.isOverflowToDisk();
  sb.append(", overflowToDisk = ").append(overflowToDisk);
  if (overflowToDisk) {
    sb.append(", maxElementsOnDisk = ").append(config.getMaxElementsOnDisk());
  }
  final boolean eternal = config.isEternal();
  sb.append(", eternal = ").append(eternal);
  if (!eternal) {
    sb.append(", timeToLiveSeconds = ").append(config.getTimeToLiveSeconds());
    sb.append(", timeToIdleSeconds = ").append(config.getTimeToIdleSeconds());
    sb.append(", memoryStoreEvictionPolicy = ")
        .append(config.getMemoryStoreEvictionPolicy());
  }
  sb.append(", diskPersistent = ").append(config.isDiskPersistent());
  sb.append(']');
  return sb.toString();
}

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

/**
 * {@inheritDoc}
 */
@Override
public String getMaxBytesLocalDiskAsString() {
  return cache.getCacheConfiguration().getMaxBytesLocalDiskAsString();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isDiskPersistent() {
  return cache.getCacheConfiguration().isDiskPersistent();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isOverflowToDisk() {
  return cache.getCacheConfiguration().isOverflowToDisk();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isLoggingEnabled() {
  return cache.getCacheConfiguration().getLogging();
}

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

/**
 * Constructor accepting the backing {@link Ehcache}
 * 
 * @param cache the cache object to use in initializing this sampled representation
 */
public CacheSamplerImpl(Ehcache cache) {
  this.cache = cache;
  cache.getCacheConfiguration().addConfigurationListener(this);
}

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

/**
 * {@inheritDoc}
 */
@Override
public long getMaxEntriesInCache() {
  return cache.getCacheConfiguration().getMaxEntriesInCache();
}

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

/**
 * {@inheritDoc}
 */
@Override
public String getMaxBytesLocalOffHeapAsString() {
  return cache.getCacheConfiguration().getMaxBytesLocalOffHeapAsString();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isEternal() {
  return cache.getCacheConfiguration().isEternal();
}

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

/**
 * {@inheritDoc}
 */
public int getWriterMaxQueueSize() {
  return ehcache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindMaxQueueSize();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isNodeBulkLoadEnabled() {
  return cache.getCacheConfiguration().isTerracottaClustered() && cache.isNodeBulkLoadEnabled();
}

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

/**
 * {@inheritDoc}
 */
@Override
public String getTerracottaConsistency() {
  Consistency consistency = this.cache.getCacheConfiguration().getTerracottaConsistency();
  return consistency != null ? consistency.name() : "na";
}

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

/**
 * {@inheritDoc}
 */
@Override
public int getWriterConcurrency() {
  return cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindConcurrency();
}

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

/**
 * {@inheritDoc}
 */
@Override
public String getPinnedToStore() {
  PinningConfiguration pinningConfig = cache.getCacheConfiguration().getPinningConfiguration();
  return pinningConfig != null ? pinningConfig.getStore().name() : "na";
}

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

/**
 * {@inheritDoc}
 */
public void notifyElementPut(Ehcache cache, Element element) throws CacheException {
  if (cache.getCacheConfiguration().isTerracottaClustered()) {
    createCacheEventReplicator(cache).notifyElementPut(cache, element);
  }
}

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

/**
 * {@inheritDoc}
 */
public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException {
  if (cache.getCacheConfiguration().isTerracottaClustered()) {
    createCacheEventReplicator(cache).notifyElementUpdated(cache, element);
  }
}

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

/**
 * {@inheritDoc}
 */
public boolean getSearchable() {
  for (String cacheName : getCacheNames()) {
    Ehcache cache = cacheManager.getEhcache(cacheName);
    if (cache != null && cache.getCacheConfiguration().getSearchable() != null) {
      return true;
    }
  }
  return false;
}

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

/**
 * {@inheritDoc}
 */
public void setMaxElementsInMemory(int maxElements) {
  if (getMaxElementsInMemory() != maxElements) {
    try {
      sampledCacheDelegate.getCache().getCacheConfiguration().setMaxElementsInMemory(maxElements);
    } catch (RuntimeException e) {
      throw Utils.newPlainException(e);
    }
  }
}

相关文章

Ehcache类方法