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


Java CacheConfiguration.setCopyOnRead方法代码示例

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


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

示例1: createMemCache

import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
public static Cache createMemCache(String name , long maxEntriesLocalHeap, long timeToLiveSeconds,
                                   long timeToIdleSeconds){
    CacheConfiguration config = new CacheConfiguration();
    config.setName(name);
    config.setEternal(false);
    config.setMaxEntriesLocalHeap(maxEntriesLocalHeap);
    config.setTimeToLiveSeconds(timeToLiveSeconds);
    config.setTimeToIdleSeconds(timeToIdleSeconds);
    config.setCopyOnRead(false);
    config.setCopyOnWrite(true);
    config.setMemoryStoreEvictionPolicy("LRU");

    CopyStrategyConfiguration copyConfig = new CopyStrategyConfiguration();
    copyConfig.setClass("org.cam.core.cache.CloneCopyStrategy");
    config.addCopyStrategy(copyConfig);

    PersistenceConfiguration persistConfig = new PersistenceConfiguration();
    persistConfig.setStrategy("NONE");
    config.addPersistence(persistConfig);

    return new Cache(config);
}
 
开发者ID:yaohuiwu,项目名称:CAM,代码行数:23,代码来源:Caches.java

示例2: tweakCacheConfiguration

import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
private static CacheConfiguration tweakCacheConfiguration(CacheConfiguration cacheConfiguration) {
  // Make copies of cached objects (use default Serializable copy)
  cacheConfiguration.setCopyOnRead(true);
  cacheConfiguration.setCopyOnWrite(true);
  cacheConfiguration.setStatistics(true);
  return cacheConfiguration;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:8,代码来源:EHCachingSearchCache.java

示例3: tweakCacheConfiguration

import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
private CacheConfiguration tweakCacheConfiguration(CacheConfiguration cacheConfiguration) {

    // Set searchable index
    Searchable uidToDocumentCacheSearchable = new Searchable();
    uidToDocumentCacheSearchable.addSearchAttribute(new SearchAttribute().name("ObjectId")
                                                        .expression("value.getObjectId().toString()"));
    uidToDocumentCacheSearchable.addSearchAttribute(new SearchAttribute().name("VersionFromInstant")
                                                        .className("com.opengamma.master.cache.InstantExtractor"));
    uidToDocumentCacheSearchable.addSearchAttribute(new SearchAttribute().name("VersionToInstant")
                                                        .className("com.opengamma.master.cache.InstantExtractor"));
    uidToDocumentCacheSearchable.addSearchAttribute(new SearchAttribute().name("CorrectionFromInstant")
                                                        .className("com.opengamma.master.cache.InstantExtractor"));
    uidToDocumentCacheSearchable.addSearchAttribute(new SearchAttribute().name("CorrectionToInstant")
                                                        .className("com.opengamma.master.cache.InstantExtractor"));
    cacheConfiguration.addSearchable(uidToDocumentCacheSearchable);

    // Make copies of cached objects
    CopyStrategyConfiguration copyStrategyConfiguration = new CopyStrategyConfiguration();
    copyStrategyConfiguration.setClass("com.opengamma.master.cache.JodaBeanCopyStrategy");
    cacheConfiguration.addCopyStrategy(copyStrategyConfiguration);
    cacheConfiguration.setCopyOnRead(true);
    cacheConfiguration.setCopyOnWrite(true);

    cacheConfiguration.setStatistics(true);

    return cacheConfiguration;
  }
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:28,代码来源:AbstractEHCachingMaster.java

示例4: testCreateCacheManual

import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
@Test
public void testCreateCacheManual() throws Exception {

    CacheConfiguration config = new CacheConfiguration();
    config.setName("queryListCache");
    config.setEternal(false);
    config.setMaxEntriesLocalHeap(1000);
    config.setTimeToLiveSeconds(3600);
    config.setTimeToIdleSeconds(3600);
    config.setCopyOnRead(false);
    config.setCopyOnWrite(true);
    config.setMemoryStoreEvictionPolicy("LRU");

    CopyStrategyConfiguration copyConfig = new CopyStrategyConfiguration();
    copyConfig.setClass("org.cam.core.cache.CloneCopyStrategy");
    config.addCopyStrategy(copyConfig);

    PersistenceConfiguration persistConfig = new PersistenceConfiguration();
    persistConfig.setStrategy("NONE");
    config.addPersistence(persistConfig);

    Cache cache = new Cache(config);

    CacheManager manager = CacheManager.getInstance();
    manager.addCache(cache);

    StringSet mySet = new StringSet(Sets.newSet("1","2"));
    cache.put(new Element("mySet",mySet));

    Element e = cache.get("mySet");
    Assert.assertNotNull(e);
    Assert.assertNotNull(e.getObjectValue());

    StringSet stringSet = (StringSet) e.getObjectValue();
    Assert.assertEquals(2 , stringSet.getIdSet().size());

    System.out.println(stringSet);
}
 
开发者ID:yaohuiwu,项目名称:CAM,代码行数:39,代码来源:InnerCacheTest.java


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