當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。