net.sf.ehcache.config.Configuration.defaultCache()方法的使用及代码示例

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

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

Configuration.defaultCache介绍

[英]Builder method to set the default cache configuration, this can only be used once.
[中]Builder方法设置默认缓存配置,此方法只能使用一次。

代码示例

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

@Before
public void setup() {
  cacheManager = new CacheManager(new Configuration().name("EhCacheCacheTests")
      .defaultCache(new CacheConfiguration("default", 100)));
  nativeCache = new net.sf.ehcache.Cache(new CacheConfiguration(CACHE_NAME, 100));
  cacheManager.addCache(nativeCache);
  cache = new EhCacheCache(nativeCache);
}

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

@Before
public void setup() {
  nativeCacheManager = new CacheManager(new Configuration().name("EhCacheCacheManagerTests")
      .defaultCache(new CacheConfiguration("default", 100)));
  addNativeCache(CACHE_NAME);
  cacheManager = new EhCacheCacheManager(nativeCacheManager);
  cacheManager.setTransactionAware(false);
  cacheManager.afterPropertiesSet();
  transactionalCacheManager = new EhCacheCacheManager(nativeCacheManager);
  transactionalCacheManager.setTransactionAware(true);
  transactionalCacheManager.afterPropertiesSet();
}

代码示例来源:origin: org.geotools/gt-s3-geotiff

private static CacheManager buildCache(CacheConfig config) {
  CacheManager manager;
  if (config.getConfigurationPath() != null) {
    manager = CacheManager.newInstance(config.getConfigurationPath());
  } else {
    Configuration cacheConfig = new Configuration();
    cacheConfig.setMaxBytesLocalDisk((long) config.getDiskCacheSize());
    cacheConfig.setMaxBytesLocalHeap((long) config.getHeapSize());
    CacheConfiguration defaultCacheConfiguration =
        new CacheConfiguration()
            .persistence(
                new PersistenceConfiguration()
                    .strategy(
                        PersistenceConfiguration.Strategy
                            .LOCALTEMPSWAP));
    cacheConfig.defaultCache(defaultCacheConfiguration);
    if (config.isUseDiskCache()) {
      DiskStoreConfiguration diskConfig = new DiskStoreConfiguration();
      diskConfig.setPath(config.getCacheDirectory().toAbsolutePath().toString());
      cacheConfig.diskStore(diskConfig);
    }
    manager = new CacheManager(cacheConfig);
    manager.addCache(DEFAULT_CACHE);
    Cache cache = manager.getCache(DEFAULT_CACHE);
    SelfPopulatingCache populatingCache =
        new SelfPopulatingCache(cache, new S3ChunkEntryFactory(config));
    manager.replaceCacheWithDecoratedCache(cache, populatingCache);
  }
  return manager;
}

相关文章

微信公众号

最新文章

更多

Configuration类方法