当前位置: 首页>>代码示例>>Java>>正文


Java CacheConfiguration.setName方法代码示例

本文整理汇总了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);
	}
}
 
开发者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: 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));
}
 
开发者ID:hengyunabc,项目名称:mybatis-ehcache-spring,代码行数:22,代码来源:MybatisEhcacheFactory.java

示例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));
}
 
开发者ID:hengyunabc,项目名称:mybatis-ehcache-spring,代码行数:22,代码来源:MybatisMetricsEhcacheFactory.java

示例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);
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:21,代码来源:DaoSpringModuleConfig.java

示例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;
}
 
开发者ID:gleb619,项目名称:hotel_shop,代码行数:24,代码来源:CacheConfig.java

示例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;
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:23,代码来源:CacheMgr.java

示例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;
}
 
开发者ID:lutece-platform,项目名称:lutece-core,代码行数:24,代码来源:CacheService.java

示例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);
}
 
开发者ID:yaohuiwu,项目名称:CAM,代码行数:23,代码来源:Caches.java

示例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()));
        }
        
    }
}
 
开发者ID:valdasraps,项目名称:resthub,代码行数:20,代码来源:CacheFactory.java

示例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;
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:11,代码来源:TestCachePoolPerformance.java

示例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);
}
 
开发者ID:Exercon,项目名称:AntiSocial-Platform,代码行数:15,代码来源:CachingConfiguration.java

示例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;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:11,代码来源:TestCachePoolPerformance.java

示例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));
    }
}
 
开发者ID:StallionCMS,项目名称:stallion-core,代码行数:30,代码来源:LocalMemoryCache.java

示例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);
}
 
开发者ID:StallionCMS,项目名称:stallion-core,代码行数:39,代码来源:FilterCache.java


注:本文中的net.sf.ehcache.config.CacheConfiguration.setName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。