本文整理汇总了Java中net.sf.ehcache.config.MemoryUnit类的典型用法代码示例。如果您正苦于以下问题:Java MemoryUnit类的具体用法?Java MemoryUnit怎么用?Java MemoryUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemoryUnit类属于net.sf.ehcache.config包,在下文中一共展示了MemoryUnit类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: BigMemoryGoStore
import net.sf.ehcache.config.MemoryUnit; //导入依赖的package包/类
public BigMemoryGoStore() {
Configuration managerConfiguration = new Configuration()
.name("benchmark")
.cache(new CacheConfiguration()
.name("store")
.maxBytesLocalHeap(50, MemoryUnit.MEGABYTES)
.maxBytesLocalOffHeap(500, MemoryUnit.MEGABYTES)
.eternal(true)
);
cacheManager = CacheManager.create(managerConfiguration);
cache = cacheManager.getCache("store");
// get notified when cache is not big enough
CacheEventListener evictionListener = new CacheEventListenerAdapter() {
@Override
public void notifyElementEvicted(Ehcache ehcache, Element element) {
cacheFull = true;
}
};
cache.getCacheEventNotificationService().registerListener(evictionListener);
}
开发者ID:bgranvea,项目名称:offheapstore-benchmark,代码行数:23,代码来源:BigMemoryGoStore.java
示例2: createEnCachePool
import net.sf.ehcache.config.MemoryUnit; //导入依赖的package包/类
public static CachePool createEnCachePool() {
CacheConfiguration cacheConf = new CacheConfiguration();
cacheConf.setName("testcache");
cacheConf.maxBytesLocalHeap(400, MemoryUnit.MEGABYTES)
.timeToIdleSeconds(3600);
Cache cache = new Cache(cacheConf);
CacheManager.create().addCache(cache);
EnchachePool enCachePool = new EnchachePool(cacheConf.getName(),cache,400*10000);
return enCachePool;
}
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:11,代码来源:TestCachePoolPerformance.java
示例3: createEnCachePool
import net.sf.ehcache.config.MemoryUnit; //导入依赖的package包/类
public static CachePool createEnCachePool() {
CacheConfiguration cacheConf = new CacheConfiguration();
cacheConf.setName("testcache");
cacheConf.maxBytesLocalHeap(400, MemoryUnit.MEGABYTES)
.timeToIdleSeconds(3600);
Cache cache = new Cache(cacheConf);
CacheManager.create().addCache(cache);
EnchachePool enCachePool = new EnchachePool(cacheConf.getName(), cache, 400 * 10000);
return enCachePool;
}
开发者ID:actiontech,项目名称:dble,代码行数:11,代码来源:TestCachePoolPerformance.java
示例4: EhCache
import net.sf.ehcache.config.MemoryUnit; //导入依赖的package包/类
public EhCache(String name, EhCacheConfiguration config) {
super(name);
String configUrl = config.getConfigUrl();
if (configUrl == null) {
CacheConfiguration cacheConfig = new CacheConfiguration();
cacheConfig.setName(name);
cacheConfig.setMemoryStoreEvictionPolicy(config.getEvictionPolicy());
cacheConfig.setMaxEntriesLocalHeap(config.getMaxHeapSize());
if (config.getMaxMemorySize() > 0) {
cacheConfig.setMaxBytesLocalHeap(MemoryUnit.BYTES.toBytes(config.getMaxMemorySize()));
}
if (config.getExpire() > 0) {
cacheConfig.timeToLiveSeconds(config.getExpire());
}
if (EhCache.Manager == null) {
EhCache.Manager = new CacheManager();
}
this.cache = new Cache(cacheConfig);
EhCache.Manager.addCache(this.cache);
} else {
EhCache.Manager = CacheManager.newInstance(configUrl);
this.cache = EhCache.Manager.getCache(name);
}
this.config = config;
}
开发者ID:PinaeOS,项目名称:timon,代码行数:31,代码来源:EhCache.java
示例5: testDistributedLoad
import net.sf.ehcache.config.MemoryUnit; //导入依赖的package包/类
@Test
@Ignore
public void testDistributedLoad() throws SyntaxException, TestException {
DistributedConfig distributedConfig = DistributedConfig.distributedConfig(address("localhost", 9911), 2);
RainfallMaster rainfallMaster = null;
CacheManager cacheManager = null;
try {
rainfallMaster = RainfallMaster.master(distributedConfig, report(EhcacheResult.class), new File("rainfall-dist")).start();
Configuration configuration = new Configuration().name("EhcacheTest")
.defaultCache(new CacheConfiguration("default", 0).eternal(true))
.cache(new CacheConfiguration().name("one")
.maxBytesLocalHeap(100, MemoryUnit.MEGABYTES));
cacheManager = CacheManager.create(configuration);
Ehcache one = cacheManager.getEhcache("one");
ConcurrencyConfig concurrency = ConcurrencyConfig.concurrencyConfig()
.threads(4).timeout(50, MINUTES);
int nbElements = 250000;
ObjectGenerator<String> keyGenerator = StringGenerator.fixedLengthString(10);
ObjectGenerator<byte[]> valueGenerator = ByteArrayGenerator.fixedLengthByteArray(1000);
Runner.setUp(
Scenario.scenario("warmup phase").exec(
put(keyGenerator, valueGenerator, new DistributedLongSequenceGenerator(distributedConfig), singletonList(cache("one", one)))
))
.executed(times(nbElements))
.config(distributedConfig)
.config(concurrency, report(EhcacheResult.class).log(text(),
html("rainfall-distributed-" + UUID.randomUUID().toString())))
.config(CacheConfig.<String, byte[]>cacheConfig().caches(one))
// .start()
;
StatisticsPeekHolder finalStats = Runner.setUp(
Scenario.scenario("Test phase").exec(
weighted(0.20,
put(keyGenerator, valueGenerator,
atRandom(Distribution.GAUSSIAN, 0, nbElements, 10000), singletonList(cache("one", one))))
,
weighted(0.80, get(String.class, byte[].class)
.atRandom(Distribution.GAUSSIAN, 0, nbElements, 10000)
.using(keyGenerator, valueGenerator))
))
.executed(during(20, seconds))
.config(concurrency, report(EhcacheResult.class).log(text(),
hlog("rainfall-distributed-" + UUID.randomUUID().toString(), true)))
.config(CacheConfig.<String, byte[]>cacheConfig().caches(one))
.config(distributedConfig)
.start();
} finally {
if (cacheManager != null) {
cacheManager.shutdown();
}
if (rainfallMaster != null) {
rainfallMaster.stop();
}
}
}
开发者ID:aurbroszniowski,项目名称:Rainfall-ehcache,代码行数:63,代码来源:PerfTest2.java
注:本文中的net.sf.ehcache.config.MemoryUnit类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论