• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MemoryUnit类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TransactionGuard类代码示例发布时间:2022-05-23
下一篇:
Java GUIOption类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap