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


Java CacheConfiguration.setMaxBytesLocalHeap方法代码示例

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


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

示例1: createCachePool

import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
@Override
public CachePool createCachePool(String poolName, int cacheSize,
		int expiredSeconds) {
	CacheManager cacheManager = CacheManager.create();
	Cache enCache = cacheManager.getCache(poolName);
	if (enCache == null) {

		CacheConfiguration cacheConf = cacheManager.getConfiguration()
				.getDefaultCacheConfiguration().clone();
		cacheConf.setName(poolName);
		if (cacheConf.getMaxEntriesLocalHeap() != 0) {
			cacheConf.setMaxEntriesLocalHeap(cacheSize);
		} else {
			cacheConf.setMaxBytesLocalHeap(String.valueOf(cacheSize));
		}
		cacheConf.setTimeToIdleSeconds(expiredSeconds);
		Cache cache = new Cache(cacheConf);
		cacheManager.addCache(cache);
		return new EnchachePool(poolName,cache,cacheSize);
	} else {
		return new EnchachePool(poolName,enCache,cacheSize);
	}
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:24,代码来源:EnchachePooFactory.java

示例2: createCachePool

import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
@Override
public CachePool createCachePool(String poolName, int cacheSize,
                                 int expiredSeconds) {
    CacheManager cacheManager = CacheManager.create();
    Cache enCache = cacheManager.getCache(poolName);
    if (enCache == null) {

        CacheConfiguration cacheConf = cacheManager.getConfiguration().getDefaultCacheConfiguration().clone();
        cacheConf.setName(poolName);
        if (cacheConf.getMaxEntriesLocalHeap() != 0) {
            cacheConf.setMaxEntriesLocalHeap(cacheSize);
        } else {
            cacheConf.setMaxBytesLocalHeap(String.valueOf(cacheSize));
        }
        cacheConf.setTimeToIdleSeconds(expiredSeconds);
        Cache cache = new Cache(cacheConf);
        cacheManager.addCache(cache);
        return new EnchachePool(poolName, cache, cacheSize);
    } else {
        return new EnchachePool(poolName, enCache, cacheSize);
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:23,代码来源:EnchachePooFactory.java

示例3: initCache

import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
public static void initCache(String bucket) {
    if (manager == null) {
        load();
    }
    if (manager.getCache(bucket) != null) {
        return;
    }
    synchronized(manager) {
        if (manager.getCache(bucket) != null) {
            return;
        }
        CacheConfiguration config = new CacheConfiguration();
        config.setName(bucket);
        // We have to do this way because there is no way to programmatically configure the
        // sizeOfEngine
        System.setProperty("net.sf.ehcache.sizeofengine.stallionLocalMemoryCache." + bucket, "io.stallion.dataAccess.filtering.EstimatedSizeOfEngine");

        // Max cache size is 100MB
        config.setMaxBytesLocalHeap(100 * 1000 * 1000L);
        //config.setDiskPersistent(false);
        //config.setMaxElementsOnDisk(0);
        //config.setMaxBytesLocalDisk(0L);
        config.setOverflowToOffHeap(false);
        PersistenceConfiguration persistenceConfiguration = new PersistenceConfiguration();
        persistenceConfiguration.strategy(PersistenceConfiguration.Strategy.NONE);
        config.persistence(persistenceConfiguration);
        manager.addCache(new Cache(config));
    }
}
 
开发者ID:StallionCMS,项目名称:stallion-core,代码行数:30,代码来源:LocalMemoryCache.java

示例4: initCache

import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
public static void initCache(String bucket) {
    if (manager == null) {
        load();
    }
    if (manager.getCache(bucket) != null) {
        return;
    }
    // We have to do this way because there is no way to programmmatically configured the
    // sizeOfEngine
    System.setProperty("net.sf.ehcache.sizeofengine.stallionFilterCache." + bucket, "io.stallion.dataAccess.filtering.EstimatedSizeOfEngine");

    CacheConfiguration config = new CacheConfiguration();
    config.setName(bucket);
    // Max cache size is very approximately, 50MB

    config.setMaxBytesLocalHeap(Settings.instance().getFilterCacheSize());
    //config.setDiskPersistent(false);
    //config.setMaxElementsOnDisk(0);
    //config.setMaxBytesLocalDisk(0L);
    config.setOverflowToOffHeap(false);
    PersistenceConfiguration persistenceConfiguration = new PersistenceConfiguration();
    persistenceConfiguration.strategy(PersistenceConfiguration.Strategy.NONE);

    config.persistence(persistenceConfiguration);
    //SizeOfPolicyConfiguration sizeOfPolicyConfiguration = new SizeOfPolicyConfiguration();
    //sizeOfPolicyConfiguration.
    //config.addSizeOfPolicy();
    //config.set
    Cache cache = new Cache(config);

    manager.addCache(cache);

    //Cache cache = manager.getCache(bucket);
    //CacheConfiguration config = cache.getCacheConfiguration();


    //config.setMaxBytesLocalHeap(150000000L);
}
 
开发者ID:StallionCMS,项目名称:stallion-core,代码行数:39,代码来源:FilterCache.java

示例5: MemoryOnlyEhcache

import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
public MemoryOnlyEhcache(String size, String namePrefix)
{
    CacheConfiguration config = new CacheConfiguration();
    config.setMaxBytesLocalHeap(size);
    config.persistence(new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.NONE));
    config.setMemoryStoreEvictionPolicy("LRU");
    config.eternal(true);
    config.setName(String.format("%s-%s", namePrefix, UUID.randomUUID().toString()));

    cache = new net.sf.ehcache.Cache(config);
    CacheManager.getInstance().addCache(cache);
}
 
开发者ID:daedafusion,项目名称:knowledge,代码行数:13,代码来源:MemoryOnlyEhcache.java

示例6: EhCache

import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的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


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