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

x33g5p2x  于2022-01-18 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(196)

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

Cache.getCacheConfiguration介绍

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

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

代码示例

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

public Map<String, Object> getCacheConfigurationInformationAsJson(Cache cache) {
  CacheConfiguration config = cache.getCacheConfiguration();
  LinkedHashMap<String, Object> json = new LinkedHashMap<>();

代码示例来源:origin: spring-projects/spring-framework

public void testCacheManagerFromConfigFile() {
  EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean();
  cacheManagerFb.setConfigLocation(new ClassPathResource("testEhcache.xml", getClass()));
  cacheManagerFb.setCacheManagerName("myCacheManager");
  cacheManagerFb.afterPropertiesSet();
  try {
    CacheManager cm = cacheManagerFb.getObject();
    assertTrue("Correct number of caches loaded", cm.getCacheNames().length == 1);
    Cache myCache1 = cm.getCache("myCache1");
    assertFalse("myCache1 is not eternal", myCache1.getCacheConfiguration().isEternal());
    assertTrue("myCache1.maxElements == 300", myCache1.getCacheConfiguration().getMaxEntriesLocalHeap() == 300);
  }
  finally {
    cacheManagerFb.destroy();
  }
}

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

/**
 * {@inheritDoc}
 */
public int getRegionCacheTargetMaxTotalCount(String region) {
  Cache cache = cacheManager.getCache(region);
  if (cache != null) {
    return cache.getCacheConfiguration().getMaxElementsOnDisk();
  } else {
    return -1;
  }
}

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

/**
 * {@inheritDoc}
 */
public boolean isTerracottaHibernateCache(String region) {
  Cache cache = cacheManager.getCache(region);
  if (cache != null) {
    return cache.getCacheConfiguration().isTerracottaClustered();
  } else {
    return false;
  }
}

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

/**
 * {@inheritDoc}
 */
public int getRegionCacheMaxTTLSeconds(String region) {
  Cache cache = cacheManager.getCache(region);
  if (cache != null) {
    return (int) cache.getCacheConfiguration().getTimeToLiveSeconds();
  } else {
    return -1;
  }
}

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

/**
 * {@inheritDoc}
 */
public int getRegionCacheMaxTTISeconds(String region) {
  Cache cache = cacheManager.getCache(region);
  if (cache != null) {
    return (int) cache.getCacheConfiguration().getTimeToIdleSeconds();
  } else {
    return -1;
  }
}

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

/**
 * {@inheritDoc}
 */
public int getRegionCacheTargetMaxInMemoryCount(String region) {
  Cache cache = cacheManager.getCache(region);
  if (cache != null) {
    return cache.getCacheConfiguration().getMaxElementsInMemory();
  } else {
    return -1;
  }
}

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

/**
 * {@inheritDoc}
 */
public boolean isRegionCacheLoggingEnabled(String region) {
  Cache cache = this.cacheManager.getCache(region);
  if (cache != null) {
    return cache.getCacheConfiguration().getLogging();
  } else {
    return false;
  }
}

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

/**
 * {@inheritDoc}
 */
public Results executeQuery(StoreQuery query) {
  if (searchManager == null) {
    throw new UnsupportedOperationException("Query execution not supported by this store type: " + getClass().getName());
  }
  DynamicAttributesExtractor dynExtractor = query.getCache().getCacheConfiguration().getDynamicExtractor();
  return searchManager.executeQuery(query, attributeExtractors, dynExtractor);
}

代码示例来源:origin: spring-projects/spring-framework

Class<? extends Ehcache> objectType2 = cacheFb.getObjectType();
assertSame(objectType, objectType2);
CacheConfiguration config = cache.getCacheConfiguration();
assertEquals("myCache1", cache.getName());
if (useCacheManagerFb){
cacheFb.afterPropertiesSet();
cache = (Cache) cacheFb.getObject();
config = cache.getCacheConfiguration();
assertEquals("undefinedCache", cache.getName());
assertTrue("default maxElements is correct", config.getMaxEntriesLocalHeap() == 10000);
cacheFb.afterPropertiesSet();
cache = (Cache) cacheFb.getObject();
config = cache.getCacheConfiguration();

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

/**
 * {@inheritDoc}
 */
public boolean isRegionCacheOrphanEvictionEnabled(String region) {
  Cache cache = this.cacheManager.getCache(region);
  if (cache != null && cache.isTerracottaClustered()) {
    return cache.getCacheConfiguration().getTerracottaConfiguration().getOrphanEviction();
  } else {
    return false;
  }
}

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

/**
 * {@inheritDoc}
 */
public void setRegionCacheLoggingEnabled(String region, boolean loggingEnabled) {
  Cache cache = this.cacheManager.getCache(region);
  if (cache != null) {
    cache.getCacheConfiguration().setLogging(loggingEnabled);
    sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region);
  }
}

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

/**
 * {@inheritDoc}
 */
public void setRegionCacheMaxTTISeconds(String region, int maxTTISeconds) {
  Cache cache = this.cacheManager.getCache(region);
  if (cache != null) {
    cache.getCacheConfiguration().setTimeToIdleSeconds(maxTTISeconds);
    sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region);
  }
}

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

/**
 * {@inheritDoc}
 */
public void setRegionCacheTargetMaxInMemoryCount(String region, int targetMaxInMemoryCount) {
  Cache cache = this.cacheManager.getCache(region);
  if (cache != null) {
    cache.getCacheConfiguration().setMaxElementsInMemory(targetMaxInMemoryCount);
    sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region);
  }
}

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

/**
 * {@inheritDoc}
 */
public void setRegionCacheTargetMaxTotalCount(String region, int targetMaxTotalCount) {
  Cache cache = this.cacheManager.getCache(region);
  if (cache != null) {
    cache.getCacheConfiguration().setMaxElementsOnDisk(targetMaxTotalCount);
    sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region);
  }
}

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

/**
 * {@inheritDoc}
 */
public int getRegionCacheOrphanEvictionPeriod(String region) {
  Cache cache = this.cacheManager.getCache(region);
  if (cache != null && cache.isTerracottaClustered()) {
   return cache.getCacheConfiguration().getTerracottaConfiguration().getOrphanEvictionPeriod();
  } else {
   return -1;
  }
}

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

/**
 * {@inheritDoc}
 */
public void setRegionCacheMaxTTLSeconds(String region, int maxTTLSeconds) {
  Cache cache = this.cacheManager.getCache(region);
  if (cache != null) {
    cache.getCacheConfiguration().setTimeToLiveSeconds(maxTTLSeconds);
    sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region);
  }
}

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

private void logOnRemoveAllIfPinnedCache() {
  PinningConfiguration pinningConfiguration = getCacheConfiguration().getPinningConfiguration();
  if (pinningConfiguration != null && PinningConfiguration.Store.INCACHE.equals(pinningConfiguration.getStore())) {
    LOG.warn("Data availability impacted:\n" +
         "****************************************************************************************\n" +
         "************************** removeAll called on a pinned cache **************************\n" +
         "****************************************************************************************");
  }
}

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

private static void validateOverAllocation(RuntimeCfg config,  Long newValue) {
  ArrayList<ConfigError> errors = new ArrayList<ConfigError>();
  for (Cache cache : getAllActiveCaches(config.cacheManager)) {
    CacheConfiguration cacheConfiguration = cache.getCacheConfiguration();
    errors.addAll(cacheConfiguration.validateCachePools(config.getConfiguration()));
    errors.addAll(cacheConfiguration.verifyPoolAllocationsBeforeAddingTo(config.cacheManager,
      newValue, config.getConfiguration().getMaxBytesLocalOffHeap(),
        config.getConfiguration().getMaxBytesLocalDisk(), null));
  }
  if (!errors.isEmpty()) {
    throw new InvalidConfigurationException("Can't reduce CacheManager byte tuning by so much", errors);
  }
}

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

/**
 * {@inheritDoc}
 */
public void init(Cache cache) throws CacheException {
  CacheWriter cacheWriter = cache.getRegisteredCacheWriter();
  if (null == cacheWriter) {
    throw new CacheException("No cache writer was registered for cache " + cache.getName());
  }
  if (cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteCoalescing()) {
    writeBehind.setOperationsFilter(new CoalesceKeysFilter());
  }
  writeBehind.start(cacheWriter);
}

相关文章

Cache类方法