当前位置: 首页>>代码示例>>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;未经允许,请勿转载。