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