當前位置: 首頁>>代碼示例>>Java>>正文


Java Configuration.addDiskStore方法代碼示例

本文整理匯總了Java中net.sf.ehcache.config.Configuration.addDiskStore方法的典型用法代碼示例。如果您正苦於以下問題:Java Configuration.addDiskStore方法的具體用法?Java Configuration.addDiskStore怎麽用?Java Configuration.addDiskStore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.sf.ehcache.config.Configuration的用法示例。


在下文中一共展示了Configuration.addDiskStore方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ServletCache

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
private ServletCache(String name, int type) {
	this.type = type;
	Configuration managerConfig = new Configuration();
	CacheConfiguration mqCf = new CacheConfiguration(name, CacheConfig
			.getConfig().getMaxElementsInMemory());
	mqCf.setEternal(true);
	DiskStoreConfiguration dsCf = new DiskStoreConfiguration();
	dsCf.setPath(CacheConfig.getConfig().getDiskStorePath());
	managerConfig.addDiskStore(dsCf);
	mqCf.setMaxElementsOnDisk(0);
	mqCf.setMaxEntriesLocalHeap(CacheConfig.getConfig()
			.getMaxElementsInMemory());
	mqCf.persistence(new PersistenceConfiguration()
			.strategy(PersistenceConfiguration.Strategy.LOCALTEMPSWAP));
	mqCf.setTransactionalMode("OFF");
	mqCf.setMemoryStoreEvictionPolicy(CacheConfig.getConfig()
			.getMemoryStoreEvictionPolicy());
	managerConfig.addCache(mqCf);
	cacheManager = new CacheManager(managerConfig);
	cache = cacheManager.getCache(name);
}
 
開發者ID:jbeetle,項目名稱:BJAF3.x,代碼行數:22,代碼來源:ServletCache.java

示例2: getCacheManager

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
private CacheManager getCacheManager() {
	if (manager == null) {
		Configuration config = new Configuration();
		CacheConfiguration cacheconfig = new CacheConfiguration(getName(), maxElementsInMemory);
		cacheconfig.setDiskExpiryThreadIntervalSeconds(diskExpiryThreadIntervalSeconds);
		cacheconfig.setDiskPersistent(diskPersistent);
		cacheconfig.setEternal(eternal);
		cacheconfig.setMaxElementsOnDisk(maxElementsOnDisk);
		cacheconfig.setMemoryStoreEvictionPolicyFromObject(memoryStoreEvictionPolicy);
		cacheconfig.setOverflowToDisk(overflowToDisk);
		cacheconfig.setTimeToIdleSeconds(timeToIdleSeconds);
		cacheconfig.setTimeToLiveSeconds(timeToLiveSeconds);

		DiskStoreConfiguration diskStoreConfigurationParameter = new DiskStoreConfiguration();
		diskStoreConfigurationParameter.setPath(getPath().getAbsolutePath());
		config.addDiskStore(diskStoreConfigurationParameter);
		config.setDefaultCacheConfiguration(cacheconfig);
		manager = new CacheManager(config);
	}
	return manager;
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:22,代碼來源:EhcacheMap.java

示例3: afterPropertiesSet

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
public void afterPropertiesSet() throws IOException, CacheException {
	log.info("Initializing EHCache CacheManager");
	Configuration config = null;
	if (this.configLocation != null) {
		config = ConfigurationFactory
				.parseConfiguration(this.configLocation.getInputStream());
		if (this.diskStoreLocation != null) {
			DiskStoreConfiguration dc = new DiskStoreConfiguration();
			dc.setPath(this.diskStoreLocation.getFile().getAbsolutePath());
			try {
				config.addDiskStore(dc);
			} catch (ObjectExistsException e) {
				log.warn("if you want to config distStore in spring,"
						+ " please remove diskStore in config file!", e);
			}
		}
	}
	if (config != null) {
		this.cacheManager = new CacheManager(config);
	} else {
		this.cacheManager = new CacheManager();
	}
	if (this.cacheManagerName != null) {
		this.cacheManager.setName(this.cacheManagerName);
	}
}
 
開發者ID:huanzhou,項目名稱:jeecms6,代碼行數:27,代碼來源:WebEhCacheManagerFacotryBean.java

示例4: PersistQueue

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
/**
 * 構造函數
 * 
 * @param block
 *            --是否為阻塞隊列,true是阻塞隊列,false是非阻塞隊列
 * @param cacheLength
 *            --內存中隊列長度,值>0;
 * @param persistDirPath
 *            --持久數據落地目錄(<b>注意:一個隊列對應一個目錄路徑,多個隊列共享一個目錄路徑,是不允許的,會出現數據不一致的情況!
 *            < /b>)
 */
public PersistQueue(final boolean block, final int cacheLength,
		final String persistDirPath) {
	if (cacheLength < 0) {
		throw new AppRuntimeException("cacheLength must >0!");
	}
	if (block) {
		this.tmpQueue = new BlockQueue();
	} else {
		this.tmpQueue = new NoBlockConcurrentQueue();
	}
	psKeys = new ConcurrentLinkedQueue<Long>();
	hcName = "pq_" + persistDirPath.hashCode();
	Configuration managerConfig = new Configuration();
	CacheConfiguration mqCf = new CacheConfiguration(hcName, cacheLength);
	mqCf.setEternal(true);
	// mqCf.setDiskStorePath(persistDirPath);
	mqCf.setMaxElementsOnDisk(0);
	mqCf.setTransactionalMode("OFF");
	mqCf.setMemoryStoreEvictionPolicy("LFU");
	// mqCf.setDiskPersistent(true);
	// mqCf.setMaxElementsInMemory(cacheLength);
	mqCf.setMaxEntriesLocalHeap(cacheLength);
	// mqCf.setOverflowToDisk(true);
	mqCf.persistence(new PersistenceConfiguration()
			.strategy(PersistenceConfiguration.Strategy.LOCALRESTARTABLE));
	managerConfig.addCache(mqCf);
	DiskStoreConfiguration dsCf = new DiskStoreConfiguration();
	dsCf.setPath(persistDirPath);
	managerConfig.addDiskStore(dsCf);
	cacheManager = new CacheManager(managerConfig);
	cache = cacheManager.getCache(hcName);
	Element e = cache.get(hcName);
	if (null == e) {
		count = new AtomicLong(0);
	} else {
		Long cv = (Long) e.getObjectValue();
		count = new AtomicLong(cv.longValue());
	}
}
 
開發者ID:jbeetle,項目名稱:BJAF3.x,代碼行數:51,代碼來源:PersistQueue.java

示例5: CacheQueue

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
/**
 * 構造函數
 * 
 * @param block
 *            --是否為阻塞隊列,true是阻塞隊列,false是非阻塞隊列
 * @param cacheLength
 *            --內存中隊列長度,值>0;
 * @param persistDirPath
 *            --數據落地目錄(<b>注意:一個隊列對應一個目錄路徑,多個隊列共享一個目錄路徑,是不允許的,會出現數據不一致的情況! <
 *            /b>)
 */
public CacheQueue(final boolean block, final int cacheLength,
		final String persistDirPath) {
	if (cacheLength < 0) {
		throw new AppRuntimeException("cacheLength must >0!");
	}
	if (block) {
		this.tmpQueue = new BlockQueue();
	} else {
		this.tmpQueue = new NoBlockConcurrentQueue();
	}
	psKeys = new ConcurrentLinkedQueue<Long>();
	hcName = "cq-" + persistDirPath.hashCode();
	Configuration managerConfig = new Configuration();
	CacheConfiguration mqCf = new CacheConfiguration(hcName, cacheLength);
	mqCf.setEternal(true);
	// mqCf.setDiskStorePath(persistDirPath);
	mqCf.setMaxElementsOnDisk(0);
	mqCf.setTransactionalMode("OFF");
	mqCf.setMemoryStoreEvictionPolicy("LFU");
	// mqCf.setDiskPersistent(true);
	// mqCf.setMaxElementsInMemory(cacheLength);
	mqCf.setMaxEntriesLocalHeap(cacheLength);
	// mqCf.setOverflowToDisk(true);
	mqCf.persistence(new PersistenceConfiguration()
			.strategy(PersistenceConfiguration.Strategy.LOCALTEMPSWAP));
	managerConfig.addCache(mqCf);
	DiskStoreConfiguration dsCf = new DiskStoreConfiguration();
	dsCf.setPath(persistDirPath);
	managerConfig.addDiskStore(dsCf);
	managerConfig.setName(hcName);
	// cacheManager = new CacheManager(managerConfig);
	cacheManager = CacheManager.newInstance(managerConfig);
	cache = cacheManager.getCache(hcName);
	count = new AtomicLong(0);
}
 
開發者ID:jbeetle,項目名稱:BJAF3.x,代碼行數:47,代碼來源:CacheQueue.java

示例6: initializeEhcacheDiskStore

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
private void initializeEhcacheDiskStore(Environment environment) {
    DiskStoreConfiguration diskStoreConfiguration = new DiskStoreConfiguration();
    diskStoreConfiguration.setPath(environment.getProperty(HmpProperties.EHCACHE_DATA_DIR));

    Configuration configuration = ConfigurationFactory.parseConfiguration();
    configuration.addDiskStore(diskStoreConfiguration);

    CacheManager.newInstance(configuration);
}
 
開發者ID:KRMAssociatesInc,項目名稱:eHMP,代碼行數:10,代碼來源:Bootstrap.java

示例7: EhCacheMemory

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
public EhCacheMemory() {
	DiskStoreConfiguration diskStoreConfiguration = new DiskStoreConfiguration();
	diskStoreConfiguration.setPath("/tmp");
	Configuration configuration = new Configuration();
	configuration.addDiskStore(diskStoreConfiguration);
	CacheConfiguration cacheConf = new CacheConfiguration("cache_memory", Integer.MAX_VALUE).memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU).overflowToDisk(false).eternal(false).diskExpiryThreadIntervalSeconds(0);
	CacheManager cacheManager = new CacheManager(configuration);
	cacheManager.addCache(new Cache(cacheConf));
	cache = cacheManager.getEhcache("cache_memory");
}
 
開發者ID:davy-zhang,項目名稱:CodeForBlog,代碼行數:11,代碼來源:EhCacheMemory.java

示例8: EhCacheDisk

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
public EhCacheDisk() {
	DiskStoreConfiguration diskStoreConfiguration = new DiskStoreConfiguration();
	diskStoreConfiguration.setPath("/tmp");
	Configuration configuration = new Configuration();
	configuration.addDiskStore(diskStoreConfiguration);
	CacheConfiguration cacheConf = new CacheConfiguration("cache_disk", 0).memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU).overflowToDisk(false).eternal(false).diskExpiryThreadIntervalSeconds(0);
	CacheManager cacheManager = new CacheManager(configuration);
	cacheManager.addCache(new Cache(cacheConf));
	cache = cacheManager.getEhcache("cache_disk");
}
 
開發者ID:davy-zhang,項目名稱:CodeForBlog,代碼行數:11,代碼來源:EhCacheDisk.java

示例9: createCacheManager

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
private CacheManager createCacheManager() throws UnsupportedEncodingException {
    Configuration configuration = new Configuration();
    configuration.setUpdateCheck(false);
    configuration.addDiskStore(diskStore());
    configuration.setDefaultCacheConfiguration(new CacheConfiguration("cache", 10000));
    return new CacheManager(configuration);
}
 
開發者ID:gocd,項目名稱:gocd,代碼行數:8,代碼來源:GoCacheFactory.java

示例10: IbisCacheManager

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
private IbisCacheManager() {
	Configuration cacheManagerConfig = new Configuration();
	String cacheDir = AppConstants.getInstance().getResolvedProperty(CACHE_DIR_KEY);
	if (StringUtils.isNotEmpty(cacheDir)) {
		log.debug("setting cache directory to ["+cacheDir+"]");
		DiskStoreConfiguration diskStoreConfiguration = new DiskStoreConfiguration();
		diskStoreConfiguration.setPath(cacheDir);
		cacheManagerConfig.addDiskStore(diskStoreConfiguration);
	} 
	CacheConfiguration defaultCacheConfig = new CacheConfiguration();
	cacheManagerConfig.addDefaultCache(defaultCacheConfig);
	cacheManager= new CacheManager(cacheManagerConfig);
}
 
開發者ID:ibissource,項目名稱:iaf,代碼行數:14,代碼來源:IbisCacheManager.java


注:本文中的net.sf.ehcache.config.Configuration.addDiskStore方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。