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


Java CacheConfiguration.setCacheLoaderFactory方法代码示例

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


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

示例1: IgniteCacheAdapter

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * Constructor.
 *
 * @param id
 *          Cache id.
 */
@SuppressWarnings("unchecked")
public IgniteCacheAdapter(String id) {
  if (id == null) {
    throw new IllegalArgumentException("Cache instances require an ID");
  }

  CacheConfiguration<Object, Object> cacheCfg = null;

  try {
    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();

    new XmlBeanDefinitionReader(factory).loadBeanDefinitions(new FileSystemResource(new File(CFG_PATH)));

    cacheCfg = (CacheConfiguration<Object, Object>) factory.getBean("templateCacheCfg");

    cacheCfg.setEvictionPolicy(null);
    cacheCfg.setCacheLoaderFactory(null);
    cacheCfg.setCacheWriterFactory(null);

    // overrides template cache name with the specified id.
    cacheCfg.setName(id);
  } catch (NoSuchBeanDefinitionException | BeanDefinitionStoreException e) {
    // initializes the default cache.
    log.warn("Initializing the default cache. Consider properly configuring '" + CFG_PATH + "' instead.");
    log.trace("" + e);

    cacheCfg = new CacheConfiguration<>(id);
  }

  cache = ignite.getOrCreateCache(cacheCfg);

  this.id = id;
}
 
开发者ID:mybatis,项目名称:ignite-cache,代码行数:40,代码来源:IgniteCacheAdapter.java

示例2: cacheConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * @param igniteInstanceName Ignite instance name.
 * @return Cache configuration.
 * @throws Exception In case of error.
 */
@SuppressWarnings("unchecked")
protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration cfg = defaultCacheConfiguration();

    cfg.setCacheMode(cacheMode());
    cfg.setAtomicityMode(atomicityMode());

    cfg.setWriteSynchronizationMode(writeSynchronization());
    cfg.setNearConfiguration(nearConfiguration());

    cfg.setCacheLoaderFactory(loaderFactory());

    if (cfg.getCacheLoaderFactory() != null)
        cfg.setReadThrough(true);

    cfg.setCacheWriterFactory(writerFactory());

    if (cfg.getCacheWriterFactory() != null)
        cfg.setWriteThrough(true);

    Factory<CacheStore> storeFactory = cacheStoreFactory();

    if (storeFactory != null) {
        cfg.setCacheStoreFactory(storeFactory);
        cfg.setReadThrough(true);
        cfg.setWriteThrough(true);
        cfg.setLoadPreviousValue(true);

        cfg.setWriteBehindEnabled(writeBehindEnabled());
        cfg.setWriteBehindCoalescing(writeBehindCoalescing());
    }

    if (cacheMode() == PARTITIONED)
        cfg.setBackups(1);

    cfg.setOnheapCacheEnabled(onheapCacheEnabled());

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:45,代码来源:IgniteCacheAbstractTest.java

示例3: cacheConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);

    ccfg.setWriteThrough(writeThrough);

    ccfg.setCacheLoaderFactory(new CacheLoaderFactory());

    ccfg.setCacheWriterFactory(new CacheWriterFactory());

    return ccfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:14,代码来源:IgniteCacheLoadAllAbstractTest.java


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