Java Code Examples for net.sf.ehcache.config.CacheConfiguration#getName()
The following examples show how to use
net.sf.ehcache.config.CacheConfiguration#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestCachePoolPerformance.java From Mycat2 with GNU General Public License v3.0 | 5 votes |
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; }
Example 2
Source File: TestCachePoolPerformance.java From dble with GNU General Public License v2.0 | 5 votes |
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; }
Example 3
Source File: EhCacheImpl.java From red5-io with Apache License 2.0 | 4 votes |
public void init() { log.info("Loading ehcache"); // log.debug("Appcontext: " + applicationContext.toString()); try { // instance the manager cm = CacheManager.getInstance(); // Use the Configuration to create our caches Configuration configuration = new Configuration(); //set initial default cache name @SuppressWarnings("unused") String defaultCacheName = Cache.DEFAULT_CACHE_NAME; //add the configs to a configuration for (CacheConfiguration conf : configs) { //set disk expiry conf.setDiskExpiryThreadIntervalSeconds(diskExpiryThreadIntervalSeconds); //set eviction policy conf.setMemoryStoreEvictionPolicy(memoryStoreEvictionPolicy); if (null == cache) { //get first cache name and use as default defaultCacheName = conf.getName(); configuration.addDefaultCache(conf); } else { configuration.addCache(conf); } } //instance the helper ConfigurationHelper helper = new ConfigurationHelper(cm, configuration); //create the default cache cache = helper.createDefaultCache(); //init the default cache.initialise(); cache.bootstrap(); //create the un-init'd caches @SuppressWarnings("unchecked") Set<Cache> caches = helper.createCaches(); if (log.isDebugEnabled()) { log.debug("Number of caches: " + caches.size() + " Default cache: " + (cache != null ? 1 : 0)); } for (Cache nonDefaultCache : caches) { nonDefaultCache.initialise(); nonDefaultCache.bootstrap(); } } catch (Exception e) { log.warn("Error on cache init", e); } if (log.isDebugEnabled()) { log.debug("Cache is null? {}", (null == cache)); } }