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


Java MutableConfiguration.setWriteThrough方法代码示例

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


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

示例1: onBeforeEachTest

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
/**
 * Configure write-through before each test.
 */
@Before
public void onBeforeEachTest() throws IOException {
  // establish and open a CacheWriterServer to handle cache
  // cache loading requests from a CacheWriterClient
  cacheWriter = new RecordingCacheWriter<>();
  cacheWriterServer = new CacheWriterServer<>(10000, cacheWriter);
  cacheWriterServer.open();

  // establish the CacheManager for the tests
  cacheManager = Caching.getCachingProvider().getCacheManager();

  // establish a CacheWriterClient that a Cache can use for writing/deleting entries
  // (via the CacheWriterServer)
  CacheWriterClient<Integer, String> theCacheWriter = new CacheWriterClient<>(cacheWriterServer.getInetAddress(),
      cacheWriterServer.getPort());

  MutableConfiguration<Integer, String> configuration = new MutableConfiguration<>();
  configuration.setTypes(Integer.class, String.class);
  configuration.setCacheWriterFactory(FactoryBuilder.factoryOf(theCacheWriter));
  configuration.setWriteThrough(true);

  getCacheManager().createCache("cache-writer-test", configuration);
  cache = getCacheManager().getCache("cache-writer-test", Integer.class, String.class);
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:28,代码来源:CacheWriterTest.java

示例2: testCreateWriteThroughCacheWithInvalidConfiguration

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test(expected = UnsupportedOperationException.class)
public void testCreateWriteThroughCacheWithInvalidConfiguration()
{
    CacheManager cacheManager = cachingProvider.getCacheManager();

    MutableConfiguration<Number, Number> configuration = new MutableConfiguration<>();

    configuration.setStoreByValue(false);
    configuration.setWriteThrough(true);

    cacheManager.createCache("cache", configuration);
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:13,代码来源:GuavaCacheManagerTest.java

示例3: setWriteThroughWithoutWriterFails

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test
public void setWriteThroughWithoutWriterFails() {
  MutableConfiguration<Long, String> config = new MutableConfiguration<>();
  config.setTypes(Long.class, String.class);
  config.setWriteThrough(true);

  try {
    merger.mergeConfigurations("cache", config);
    fail("Expected exception as no CacheLoader factory is configured and read-through is enabled.");
  } catch (IllegalArgumentException e) {
    assertThat(e.getMessage(), containsString("write-through"));
  }
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:14,代码来源:ConfigurationMergerTest.java

示例4: getConfiguration

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
private MutableConfiguration<Long, String> getConfiguration(final boolean readThrough, final CacheLoader<Long, String> cacheLoader,
                                                            final boolean writeThrough, final CacheWriter<Long, String> cacheWriter) {
  MutableConfiguration<Long, String> config = new MutableConfiguration<>();
  config.setTypes(Long.class, String.class);
  config.setReadThrough(readThrough);
  config.setCacheLoaderFactory(() -> cacheLoader);
  config.setWriteThrough(writeThrough);
  config.setCacheWriterFactory(() -> cacheWriter);
  return config;
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:11,代码来源:LoaderWriterConfigTest.java

示例5: onBeforeEachTest

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
/**
 * Establish the {@link javax.cache.CacheManager} and {@link Cache} for a test.
 */
@Before
public void onBeforeEachTest() throws IOException {
  //establish and open a CacheLoaderServer to handle cache
  //cache loading requests from a CacheLoaderClient
  recordingCacheLoader = new RecordingCacheLoader<String>();
  cacheLoaderServer = new CacheLoaderServer<String, String>(10000, recordingCacheLoader);
  cacheLoaderServer.open();

  // establish and open a CacheWriterServer to handle cache
  // cache loading requests from a CacheWriterClient
  recordingCacheWriter = new RecordingCacheWriter<>();
  cacheWriterServer = new CacheWriterServer<>(10001, recordingCacheWriter);
  cacheWriterServer.open();

  //establish the CacheManager for the tests
  cacheManager = Caching.getCachingProvider().getCacheManager();

  //establish a CacheLoaderClient that a Cache can use for loading entries
  //(via the CacheLoaderServer)
  CacheLoaderClient<String, String> cacheLoader =
      new CacheLoaderClient<>(cacheLoaderServer.getInetAddress(), cacheLoaderServer.getPort());

  // establish a CacheWriterClient that a Cache can use for writing/deleting entries
  // (via the CacheWriterServer)
  CacheWriterClient<String, String> cacheWriter = new CacheWriterClient<>(cacheWriterServer.getInetAddress(),
      cacheWriterServer.getPort());

  //establish a Cache Configuration that uses a CacheLoader and Read-Through
  MutableConfiguration<String, String> configuration = new MutableConfiguration<>();
  configuration.setTypes(String.class, String.class);
  configuration.setCacheLoaderFactory(FactoryBuilder.factoryOf(cacheLoader));
  configuration.setReadThrough(true);
  configuration.setCacheWriterFactory(FactoryBuilder.factoryOf(cacheWriter));
  configuration.setWriteThrough(true);

  //configure the cache
  cacheManager.createCache("cache-loader-writer-test", configuration);
  cache = cacheManager.getCache("cache-loader-writer-test", String.class, String.class);
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:43,代码来源:CacheLoaderWriterTest.java


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