本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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);
}