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

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

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

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

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

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

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

  1. private String buildConfiguration(Object cache) {
  2. final StringBuilder sb = new StringBuilder();
  3. // getCacheConfiguration() et getMaxElementsOnDisk() n'existent pas en ehcache 1.2
  4. final CacheConfiguration config = ((Ehcache) cache).getCacheConfiguration();
  5. sb.append("ehcache [maxElementsInMemory = ").append(config.getMaxElementsInMemory());
  6. final boolean overflowToDisk = config.isOverflowToDisk();
  7. sb.append(", overflowToDisk = ").append(overflowToDisk);
  8. if (overflowToDisk) {
  9. sb.append(", maxElementsOnDisk = ").append(config.getMaxElementsOnDisk());
  10. }
  11. final boolean eternal = config.isEternal();
  12. sb.append(", eternal = ").append(eternal);
  13. if (!eternal) {
  14. sb.append(", timeToLiveSeconds = ").append(config.getTimeToLiveSeconds());
  15. sb.append(", timeToIdleSeconds = ").append(config.getTimeToIdleSeconds());
  16. sb.append(", memoryStoreEvictionPolicy = ")
  17. .append(config.getMemoryStoreEvictionPolicy());
  18. }
  19. sb.append(", diskPersistent = ").append(config.isDiskPersistent());
  20. sb.append(']');
  21. return sb.toString();
  22. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public String getMaxBytesLocalDiskAsString() {
  6. return cache.getCacheConfiguration().getMaxBytesLocalDiskAsString();
  7. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public boolean isDiskPersistent() {
  6. return cache.getCacheConfiguration().isDiskPersistent();
  7. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public boolean isOverflowToDisk() {
  6. return cache.getCacheConfiguration().isOverflowToDisk();
  7. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public boolean isLoggingEnabled() {
  6. return cache.getCacheConfiguration().getLogging();
  7. }

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

  1. /**
  2. * Constructor accepting the backing {@link Ehcache}
  3. *
  4. * @param cache the cache object to use in initializing this sampled representation
  5. */
  6. public CacheSamplerImpl(Ehcache cache) {
  7. this.cache = cache;
  8. cache.getCacheConfiguration().addConfigurationListener(this);
  9. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public long getMaxEntriesInCache() {
  6. return cache.getCacheConfiguration().getMaxEntriesInCache();
  7. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public String getMaxBytesLocalOffHeapAsString() {
  6. return cache.getCacheConfiguration().getMaxBytesLocalOffHeapAsString();
  7. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public boolean isEternal() {
  6. return cache.getCacheConfiguration().isEternal();
  7. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public int getWriterMaxQueueSize() {
  5. return ehcache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindMaxQueueSize();
  6. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public boolean isNodeBulkLoadEnabled() {
  6. return cache.getCacheConfiguration().isTerracottaClustered() && cache.isNodeBulkLoadEnabled();
  7. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public String getTerracottaConsistency() {
  6. Consistency consistency = this.cache.getCacheConfiguration().getTerracottaConsistency();
  7. return consistency != null ? consistency.name() : "na";
  8. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public int getWriterConcurrency() {
  6. return cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindConcurrency();
  7. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public String getPinnedToStore() {
  6. PinningConfiguration pinningConfig = cache.getCacheConfiguration().getPinningConfiguration();
  7. return pinningConfig != null ? pinningConfig.getStore().name() : "na";
  8. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public void notifyElementPut(Ehcache cache, Element element) throws CacheException {
  5. if (cache.getCacheConfiguration().isTerracottaClustered()) {
  6. createCacheEventReplicator(cache).notifyElementPut(cache, element);
  7. }
  8. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException {
  5. if (cache.getCacheConfiguration().isTerracottaClustered()) {
  6. createCacheEventReplicator(cache).notifyElementUpdated(cache, element);
  7. }
  8. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public boolean getSearchable() {
  5. for (String cacheName : getCacheNames()) {
  6. Ehcache cache = cacheManager.getEhcache(cacheName);
  7. if (cache != null && cache.getCacheConfiguration().getSearchable() != null) {
  8. return true;
  9. }
  10. }
  11. return false;
  12. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public void setMaxElementsInMemory(int maxElements) {
  5. if (getMaxElementsInMemory() != maxElements) {
  6. try {
  7. sampledCacheDelegate.getCache().getCacheConfiguration().setMaxElementsInMemory(maxElements);
  8. } catch (RuntimeException e) {
  9. throw Utils.newPlainException(e);
  10. }
  11. }
  12. }

相关文章

Ehcache类方法