当前位置: 首页>>代码示例>>Java>>正文


Java CacheManagerBuilder.newCacheManagerBuilder方法代码示例

本文整理汇总了Java中org.ehcache.config.builders.CacheManagerBuilder.newCacheManagerBuilder方法的典型用法代码示例。如果您正苦于以下问题:Java CacheManagerBuilder.newCacheManagerBuilder方法的具体用法?Java CacheManagerBuilder.newCacheManagerBuilder怎么用?Java CacheManagerBuilder.newCacheManagerBuilder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ehcache.config.builders.CacheManagerBuilder的用法示例。


在下文中一共展示了CacheManagerBuilder.newCacheManagerBuilder方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCacheManager

import org.ehcache.config.builders.CacheManagerBuilder; //导入方法依赖的package包/类
CacheManager createCacheManager() throws IOException {
    CacheManager manager;

    if (cacheManager != null) {
        manager = cacheManager;
    } else if (configUri != null) {
        manager = CacheManagerBuilder.newCacheManager(new XmlConfiguration(getConfigUriAsUrl()));
    } else {
        CacheManagerBuilder builder = CacheManagerBuilder.newCacheManagerBuilder();
        if (configuration != null) {
            builder.withCache(cacheName, configuration);
        }

        manager = builder.build();
    }

    return manager;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:EhcacheConfiguration.java

示例2: testPutAll_without_cache_writer

import org.ehcache.config.builders.CacheManagerBuilder; //导入方法依赖的package包/类
@Test
public void testPutAll_without_cache_writer() throws Exception {
  CacheConfigurationBuilder cacheConfigurationBuilder = CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, String.class,
      heap(100));
  CacheConfiguration<String, String> cacheConfiguration = cacheConfigurationBuilder.build();

  CacheManagerBuilder<CacheManager> managerBuilder = CacheManagerBuilder.newCacheManagerBuilder();
  CacheManager cacheManager = managerBuilder.withCache("myCache", cacheConfiguration).build(true);

  Cache<String, String> myCache = cacheManager.getCache("myCache", String.class, String.class);

  HashMap<String, String> stringStringHashMap = new HashMap<>();
  for (int i = 0; i < 3; i++) {
    stringStringHashMap.put("key" + i, "value" + i);
  }

  // the call to putAll
  myCache.putAll(stringStringHashMap);

  for (int i = 0; i < 3; i++) {
    assertThat(myCache.get("key" + i), is("value" + i));
  }

}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:25,代码来源:EhcacheBulkMethodsITest.java

示例3: testAddingWriteBehindConfigurationAtCacheLevel

import org.ehcache.config.builders.CacheManagerBuilder; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testAddingWriteBehindConfigurationAtCacheLevel() {
  CacheManagerBuilder<CacheManager> cacheManagerBuilder = CacheManagerBuilder.newCacheManagerBuilder();
  WriteBehindConfiguration writeBehindConfiguration = WriteBehindConfigurationBuilder.newBatchedWriteBehindConfiguration(Long.MAX_VALUE, SECONDS, 1)
      .concurrencyLevel(3)
      .queueSize(10)
      .build();
  Class<CacheLoaderWriter<?, ?>> klazz = (Class<CacheLoaderWriter<?, ?>>) (Class) (SampleLoaderWriter.class);
  CacheManager cacheManager = cacheManagerBuilder.build(true);
  final Cache<Long, String> cache = cacheManager.createCache("cache",
      CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, heap(100))
          .add(writeBehindConfiguration)
          .add(new DefaultCacheLoaderWriterConfiguration(klazz))
          .build());
  Collection<ServiceConfiguration<?>> serviceConfiguration = cache.getRuntimeConfiguration()
      .getServiceConfigurations();
  assertThat(serviceConfiguration, IsCollectionContaining.<ServiceConfiguration<?>>hasItem(instanceOf(WriteBehindConfiguration.class)));
  cacheManager.close();
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:21,代码来源:WriteBehindProviderFactoryTest.java

示例4: testGetAll_without_cache_loader

import org.ehcache.config.builders.CacheManagerBuilder; //导入方法依赖的package包/类
@Test
public void testGetAll_without_cache_loader() throws Exception {
  CacheConfigurationBuilder cacheConfigurationBuilder = CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, String.class,
      heap(100));
  CacheConfiguration<String, String> cacheConfiguration = cacheConfigurationBuilder.build();

  CacheManagerBuilder<CacheManager> managerBuilder = CacheManagerBuilder.newCacheManagerBuilder();
  CacheManager cacheManager = managerBuilder.withCache("myCache", cacheConfiguration).build(true);

  Cache<String, String> myCache = cacheManager.getCache("myCache", String.class, String.class);

  for (int i = 0; i < 3; i++) {
    myCache.put("key" + i, "value" + i);
  }

  Set<String> fewKeysSet = new HashSet<String>() {
    {
      add("key0");
      add("key2");
    }
  };
  // the call to getAll
  Map<String, String> fewEntries = myCache.getAll(fewKeysSet);

  assertThat(fewEntries.size(), is(2));
  assertThat(fewEntries.get("key0"), is("value0"));
  assertThat(fewEntries.get("key2"), is("value2"));

}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:30,代码来源:EhcacheBulkMethodsITest.java

示例5: testRemoveAll_without_cache_writer

import org.ehcache.config.builders.CacheManagerBuilder; //导入方法依赖的package包/类
@Test
public void testRemoveAll_without_cache_writer() throws Exception {
  CacheConfigurationBuilder cacheConfigurationBuilder = CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, String.class,
      heap(100));
  CacheConfiguration<String, String> cacheConfiguration = cacheConfigurationBuilder.build();

  CacheManagerBuilder<CacheManager> managerBuilder = CacheManagerBuilder.newCacheManagerBuilder();
  CacheManager cacheManager = managerBuilder.withCache("myCache", cacheConfiguration).build(true);

  Cache<String, String> myCache = cacheManager.getCache("myCache", String.class, String.class);

  for (int i = 0; i < 3; i++) {
    myCache.put("key" + i, "value" + i);
  }

  Set<String> fewKeysSet = new HashSet<String>() {
    {
      add("key0");
      add("key2");
    }
  };
  // the call to removeAll
  myCache.removeAll(fewKeysSet);

  for (int i = 0; i < 3; i++) {
    if (i == 0 || i == 2) {
      assertThat(myCache.get("key" + i), is(nullValue()));
    } else {
      assertThat(myCache.get("key" + i), is("value" + i));
    }
  }

}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:34,代码来源:EhcacheBulkMethodsITest.java

示例6: testAddingCacheLoaderWriterConfigurationAtCacheLevel

import org.ehcache.config.builders.CacheManagerBuilder; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testAddingCacheLoaderWriterConfigurationAtCacheLevel() {
  CacheManagerBuilder<CacheManager> cacheManagerBuilder = CacheManagerBuilder.newCacheManagerBuilder();
  Class<CacheLoaderWriter<?, ?>> klazz = (Class<CacheLoaderWriter<?, ?>>) (Class) (MyLoader.class);
  CacheManager cacheManager = cacheManagerBuilder.build(true);
  final Cache<Long, String> cache = cacheManager.createCache("cache",
      CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, heap(100))
          .add(new DefaultCacheLoaderWriterConfiguration(klazz))
          .build());
  Collection<ServiceConfiguration<?>> serviceConfiguration = cache.getRuntimeConfiguration()
      .getServiceConfigurations();
  assertThat(serviceConfiguration, IsCollectionContaining.<ServiceConfiguration<?>>hasItem(instanceOf(DefaultCacheLoaderWriterConfiguration.class)));
  cacheManager.close();
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:16,代码来源:DefaultCacheLoaderWriterProviderTest.java

示例7: testAddingCacheEventListenerConfigurationAtCacheLevel

import org.ehcache.config.builders.CacheManagerBuilder; //导入方法依赖的package包/类
@Test
public void testAddingCacheEventListenerConfigurationAtCacheLevel() {
  CacheManagerBuilder<CacheManager> cacheManagerBuilder = CacheManagerBuilder.newCacheManagerBuilder();
  CacheEventListenerConfiguration cacheEventListenerConfiguration = CacheEventListenerConfigurationBuilder
      .newEventListenerConfiguration(ListenerObject.class, EventType.CREATED).unordered().asynchronous().build();
  CacheManager cacheManager = cacheManagerBuilder.build(true);
  final Cache<Long, String> cache = cacheManager.createCache("cache",
      CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, heap(100))
          .add(cacheEventListenerConfiguration)
          .build());
  Collection<ServiceConfiguration<?>> serviceConfiguration = cache.getRuntimeConfiguration()
      .getServiceConfigurations();
  assertThat(serviceConfiguration, IsCollectionContaining.<ServiceConfiguration<?>>hasItem(instanceOf(DefaultCacheEventListenerConfiguration.class)));
  cacheManager.close();
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:16,代码来源:DefaultCacheEventListenerProviderTest.java

示例8: setUp

import org.ehcache.config.builders.CacheManagerBuilder; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  CacheManagerBuilder<CacheManager> builder = CacheManagerBuilder.newCacheManagerBuilder();
  cacheManager = builder.build(true);
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:6,代码来源:EvictionEhcacheTest.java


注:本文中的org.ehcache.config.builders.CacheManagerBuilder.newCacheManagerBuilder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。