本文整理汇总了Java中net.sf.ehcache.config.CacheConfiguration.setName方法的典型用法代码示例。如果您正苦于以下问题:Java CacheConfiguration.setName方法的具体用法?Java CacheConfiguration.setName怎么用?Java CacheConfiguration.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.ehcache.config.CacheConfiguration
的用法示例。
在下文中一共展示了CacheConfiguration.setName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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);
}
}
示例3: getCache
import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
@Override
public Cache getCache(String id) {
if (id == null) {
throw new IllegalArgumentException("Cache instances require an ID");
}
if (!cacheManager.cacheExists(id)) {
CacheConfiguration temp = null;
if (cacheConfiguration != null) {
temp = cacheConfiguration.clone();
} else {
// based on defaultCache
temp = cacheManager.getConfiguration().getDefaultCacheConfiguration().clone();
}
temp.setName(id);
net.sf.ehcache.Cache cache = new net.sf.ehcache.Cache(temp);
cacheManager.addCache(cache);
}
return new EhcacheCache(id, cacheManager.getEhcache(id));
}
示例4: getCache
import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
@Override
public Cache getCache(String id) {
if (id == null) {
throw new IllegalArgumentException("Cache instances require an ID");
}
if (!cacheManager.cacheExists(id)) {
CacheConfiguration temp = null;
if (cacheConfiguration != null) {
temp = cacheConfiguration.clone();
} else {
// based on defaultCache
temp = cacheManager.getConfiguration().getDefaultCacheConfiguration().clone();
}
temp.setName(id);
net.sf.ehcache.Cache cache = new net.sf.ehcache.Cache(temp);
Ehcache instrumentCache = InstrumentedEhcache.instrument(registry, cache);
cacheManager.addCache(instrumentCache);
}
return new EhcacheCache(id, cacheManager.getEhcache(id));
}
示例5: ehCacheManager
import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
/**
* Gets an EH Cache manager.
*
* @return the EH Cache manager.
*/
@Bean(destroyMethod = "shutdown")
public net.sf.ehcache.CacheManager ehCacheManager()
{
CacheConfiguration cacheConfiguration = new CacheConfiguration();
cacheConfiguration.setName(HERD_CACHE_NAME);
cacheConfiguration.setTimeToLiveSeconds(configurationHelper.getProperty(ConfigurationValue.HERD_CACHE_TIME_TO_LIVE_SECONDS, Long.class));
cacheConfiguration.setTimeToIdleSeconds(configurationHelper.getProperty(ConfigurationValue.HERD_CACHE_TIME_TO_IDLE_SECONDS, Long.class));
cacheConfiguration.setMaxElementsInMemory(configurationHelper.getProperty(ConfigurationValue.HERD_CACHE_MAX_ELEMENTS_IN_MEMORY, Integer.class));
cacheConfiguration.setMemoryStoreEvictionPolicy(configurationHelper.getProperty(ConfigurationValue.HERD_CACHE_MEMORY_STORE_EVICTION_POLICY));
net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration();
config.addCache(cacheConfiguration);
return net.sf.ehcache.CacheManager.create(config);
}
示例6: loadCache
import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
/**
* Load cache.
*
* @param name the name
* @return the cache configuration
*/
private CacheConfiguration loadCache(String name) {
CacheConfiguration cacheConfiguration = new CacheConfiguration();
cacheConfiguration.setMemoryStoreEvictionPolicy("LRU");
cacheConfiguration.setMaxEntriesLocalHeap(10000);
cacheConfiguration.setMaxEntriesLocalDisk(1000000);
if (debug) {
cacheConfiguration.setTimeToIdleSeconds(1);
cacheConfiguration.setTimeToLiveSeconds(2);
}
else {
cacheConfiguration.setTimeToIdleSeconds(10);
cacheConfiguration.setTimeToLiveSeconds(20);
}
cacheConfiguration.setName(name);
return cacheConfiguration;
}
示例7: getEHCache
import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
private synchronized static Cache getEHCache(String cacheName, CacheType type) {
CacheManager mgr = getEHCacheManager();
cacheName = type.getCacheName(cacheName);
Cache ret = mgr.getCache(cacheName);
if (ret == null) {
// create new cache by cloning from the appropriate cache
CacheConfiguration config = null;
if (type == CacheType.CUSTOM) {
throw new IllegalStateException("CacheName: " + cacheName + ", does not exist in ehcache.xml");
} else if (type == CacheType.SESSION_MEMORY) {
config = mgr.getCache("CacheMgrSess").getCacheConfiguration().clone();
} else if (type == CacheType.DISK) {
config = mgr.getCache("CacheMgrDisk").getCacheConfiguration().clone();
} else {
config = mgr.getCache("CacheMgrMem").getCacheConfiguration().clone();
}
config.setName(cacheName);
ret = new Cache(config);
mgr.addCache(ret);
}
return ret;
}
示例8: getCacheConfiguration
import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
/**
* Read cache config from the file caches.dat
*
* @param strCacheName
* The cache name
* @return The config
*/
private CacheConfiguration getCacheConfiguration( String strCacheName )
{
CacheConfiguration config = new CacheConfiguration( );
config.setName( strCacheName );
config.setMaxElementsInMemory( getIntProperty( strCacheName, PROPERTY_MAX_ELEMENTS, _nDefaultMaxElementsInMemory ) );
config.setEternal( getBooleanProperty( strCacheName, PROPERTY_ETERNAL, _bDefaultEternal ) );
config.setTimeToIdleSeconds( getLongProperty( strCacheName, PROPERTY_TIME_TO_IDLE, _lDefaultTimeToIdle ) );
config.setTimeToLiveSeconds( getLongProperty( strCacheName, PROPERTY_TIME_TO_LIVE, _lDefaultTimeToLive ) );
config.setOverflowToDisk( getBooleanProperty( strCacheName, PROPERTY_OVERFLOW_TO_DISK, _bDefaultOverflowToDisk ) );
config.setDiskPersistent( getBooleanProperty( strCacheName, PROPERTY_DISK_PERSISTENT, _bDefaultDiskPersistent ) );
config.setDiskExpiryThreadIntervalSeconds( getLongProperty( strCacheName, PROPERTY_DISK_EXPIRY, _lDefaultDiskExpiry ) );
config.setMaxElementsOnDisk( getIntProperty( strCacheName, PROPERTY_MAX_ELEMENTS_DISK, _nDefaultMaxElementsOnDisk ) );
config.setStatistics( getBooleanProperty( strCacheName, PROPERTY_STATISTICS, _bDefaultStatistics ) );
return config;
}
示例9: createMemCache
import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
public static Cache createMemCache(String name , long maxEntriesLocalHeap, long timeToLiveSeconds,
long timeToIdleSeconds){
CacheConfiguration config = new CacheConfiguration();
config.setName(name);
config.setEternal(false);
config.setMaxEntriesLocalHeap(maxEntriesLocalHeap);
config.setTimeToLiveSeconds(timeToLiveSeconds);
config.setTimeToIdleSeconds(timeToIdleSeconds);
config.setCopyOnRead(false);
config.setCopyOnWrite(true);
config.setMemoryStoreEvictionPolicy("LRU");
CopyStrategyConfiguration copyConfig = new CopyStrategyConfiguration();
copyConfig.setClass("org.cam.core.cache.CloneCopyStrategy");
config.addCopyStrategy(copyConfig);
PersistenceConfiguration persistConfig = new PersistenceConfiguration();
persistConfig.setStrategy("NONE");
config.addPersistence(persistConfig);
return new Cache(config);
}
示例10: add
import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
public void add(Query query) {
String name = query.getQid().getId();
if (!this.manager.cacheExists(name) && query.isCacheable()) {
CacheConfiguration config = defaultConfig.clone();
config.setName(name);
config.setEternal(query.isEternal());
config.setTimeToLiveSeconds(query.getCacheTime());
Cache c = new Cache(config);
this.manager.addCache(c);
if (log.isDebugEnabled()) {
log.debug(String.format("Cache %s created: eternal = %s, cacheTime = %d",
c.getName(), query.isEternal(), query.getCacheTime()));
}
}
}
示例11: createEnCachePool
import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的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;
}
示例12: ehCacheManager
import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的package包/类
@Bean(destroyMethod="shutdown")
public net.sf.ehcache.CacheManager ehCacheManager() {
CacheConfiguration cacheConfiguration = new CacheConfiguration();
cacheConfiguration.setName("categoryCache");
cacheConfiguration.setMemoryStoreEvictionPolicy("LRU");
cacheConfiguration.setMaxEntriesLocalHeap(1000);
net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration();
//config.addCache(cacheConfiguration);
config.defaultCache(cacheConfiguration);
return net.sf.ehcache.CacheManager.newInstance(config);
}
示例13: createEnCachePool
import net.sf.ehcache.config.CacheConfiguration; //导入方法依赖的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;
}
示例14: 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));
}
}
示例15: 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);
}