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


Java CacheConfiguration类代码示例

本文整理汇总了Java中net.sf.ehcache.config.CacheConfiguration的典型用法代码示例。如果您正苦于以下问题:Java CacheConfiguration类的具体用法?Java CacheConfiguration怎么用?Java CacheConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CacheConfiguration类属于net.sf.ehcache.config包,在下文中一共展示了CacheConfiguration类的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: afterPropertiesSet

import net.sf.ehcache.config.CacheConfiguration; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
    if (this.serviceTicketsCache == null || this.ticketGrantingTicketsCache == null) {
        throw new BeanInstantiationException(this.getClass(),
                "Both serviceTicketsCache and ticketGrantingTicketsCache are required properties.");
    }

    if (logger.isDebugEnabled()) {
        CacheConfiguration config = this.serviceTicketsCache.getCacheConfiguration();
        logger.debug("serviceTicketsCache.maxElementsInMemory={}", config.getMaxEntriesLocalHeap());
        logger.debug("serviceTicketsCache.maxElementsOnDisk={}", config.getMaxElementsOnDisk());
        logger.debug("serviceTicketsCache.isOverflowToDisk={}", config.isOverflowToDisk());
        logger.debug("serviceTicketsCache.timeToLive={}", config.getTimeToLiveSeconds());
        logger.debug("serviceTicketsCache.timeToIdle={}", config.getTimeToIdleSeconds());
        logger.debug("serviceTicketsCache.cacheManager={}", this.serviceTicketsCache.getCacheManager().getName());

        config = this.ticketGrantingTicketsCache.getCacheConfiguration();
        logger.debug("ticketGrantingTicketsCache.maxElementsInMemory={}", config.getMaxEntriesLocalHeap());
        logger.debug("ticketGrantingTicketsCache.maxElementsOnDisk={}", config.getMaxElementsOnDisk());
        logger.debug("ticketGrantingTicketsCache.isOverflowToDisk={}", config.isOverflowToDisk());
        logger.debug("ticketGrantingTicketsCache.timeToLive={}", config.getTimeToLiveSeconds());
        logger.debug("ticketGrantingTicketsCache.timeToIdle={}", config.getTimeToIdleSeconds());
        logger.debug("ticketGrantingTicketsCache.cacheManager={}", this.ticketGrantingTicketsCache.getCacheManager()
                .getName());
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:EhCacheTicketRegistry.java

示例3: EhCacheTicketRegistry

import net.sf.ehcache.config.CacheConfiguration; //导入依赖的package包/类
/**
 * Instantiates a new EhCache ticket registry.
 *
 * @param ticketCache          the ticket cache
 * @param cipher               the cipher
 */
public EhCacheTicketRegistry(final Cache ticketCache, final CipherExecutor cipher) {
    this.ehcacheTicketsCache = ticketCache;
    setCipherExecutor(cipher);

    LOGGER.info("Setting up Ehcache Ticket Registry...");

    Assert.notNull(this.ehcacheTicketsCache, "Ehcache Tickets cache cannot nbe null");
    if (LOGGER.isDebugEnabled()) {
        final CacheConfiguration config = this.ehcacheTicketsCache.getCacheConfiguration();
        LOGGER.debug("TicketCache.maxEntriesLocalHeap=[{}]", config.getMaxEntriesLocalHeap());
        LOGGER.debug("TicketCache.maxEntriesLocalDisk=[{}]", config.getMaxEntriesLocalDisk());
        LOGGER.debug("TicketCache.maxEntriesInCache=[{}]", config.getMaxEntriesInCache());
        LOGGER.debug("TicketCache.persistenceConfiguration=[{}]", config.getPersistenceConfiguration().getStrategy());
        LOGGER.debug("TicketCache.synchronousWrites=[{}]", config.getPersistenceConfiguration().getSynchronousWrites());
        LOGGER.debug("TicketCache.timeToLive=[{}]", config.getTimeToLiveSeconds());
        LOGGER.debug("TicketCache.timeToIdle=[{}]", config.getTimeToIdleSeconds());
        LOGGER.debug("TicketCache.cacheManager=[{}]", this.ehcacheTicketsCache.getCacheManager().getName());
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:26,代码来源:EhCacheTicketRegistry.java

示例4: EhCacheWrapper

import net.sf.ehcache.config.CacheConfiguration; //导入依赖的package包/类
/**
 * http://www.ehcache.org/documentation/2.8/code-samples.html#creating-caches-programmatically
 */
EhCacheWrapper(String cacheName) {
    AppConfiguration.Cache config = AppConfiguration.CONFIG.getCache();

    // Create a Cache specifying its configuration
    cache = new Cache(
            new CacheConfiguration(cacheName, config.getMaxSize())
                    .timeToLiveSeconds(TimeUnit.MINUTES.toSeconds(config.getLifeTime()))
                    .eternal(false)
                    .persistence(new PersistenceConfiguration().strategy(Strategy.NONE))
                    .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.FIFO)
    );

    // The cache is not usable until it has been added
    manager.addCache(cache);
}
 
开发者ID:RWTH-i5-IDSG,项目名称:xsharing-services-router,代码行数:19,代码来源:EhCacheWrapper.java

示例5: 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

示例6: initCache

import net.sf.ehcache.config.CacheConfiguration; //导入依赖的package包/类
public static void initCache(String bucket) {
    if (manager == null) {
        load();
    }
    if (manager.getCache(bucket) != null) {
        return;
    }
    CacheConfiguration config = new CacheConfiguration(bucket, 10000);
    //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,代码行数:18,代码来源:SmartQueryCache.java

示例7: NcwmsCatalogue

import net.sf.ehcache.config.CacheConfiguration; //导入依赖的package包/类
public NcwmsCatalogue(NcwmsConfig config) throws IOException {
    super(config, new SimpleLayerNameMapper());
    this.styleCatalogue = SldTemplateStyleCatalogue.getStyleCatalogue();

    if (cacheManager.cacheExists(CACHE_NAME) == false) {
        /*
         * Configure cache
         */
        CacheConfiguration cacheConfig = new CacheConfiguration(CACHE_NAME, MAX_HEAP_ENTRIES)
                .eternal(true)
                .memoryStoreEvictionPolicy(EVICTION_POLICY)
                .persistence(new PersistenceConfiguration().strategy(PERSISTENCE_STRATEGY))
                .transactionalMode(TRANSACTIONAL_MODE);
        dynamicDatasetCache = new Cache(cacheConfig);
        cacheManager.addCache(dynamicDatasetCache);
    } else {
        dynamicDatasetCache = cacheManager.getCache(CACHE_NAME);
    }
}
 
开发者ID:Reading-eScience-Centre,项目名称:ncwms,代码行数:20,代码来源:NcwmsCatalogue.java

示例8: ServletCache

import net.sf.ehcache.config.CacheConfiguration; //导入依赖的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

示例9: EHCachingSearchCache

import net.sf.ehcache.config.CacheConfiguration; //导入依赖的package包/类
/**
 * Create a new search cache.
 *
 * @param name  a unique name for this cache, not empty
 * @param cacheManager  the cache manager to use, not null
 * @param searcher  the CacheSearcher to use for passing search requests to an underlying master, not null
 */
public EHCachingSearchCache(String name, CacheManager cacheManager, Searcher searcher) {
  ArgumentChecker.notNull(cacheManager, "cacheManager");
  ArgumentChecker.notEmpty(name, "name");
  ArgumentChecker.notNull(searcher, "searcher");

  _cacheManager = cacheManager;
  _searcher = searcher;

  // Load cache configuration
  if (cacheManager.getCache(name + CACHE_NAME_SUFFIX) == null) {
    // If cache config not found, set up programmatically
    s_logger.warn("Could not load a cache configuration for " + name + CACHE_NAME_SUFFIX
                + ", building a default configuration programmatically instead");
    getCacheManager().addCache(new Cache(tweakCacheConfiguration(new CacheConfiguration(name + CACHE_NAME_SUFFIX,
                                                                                        10000))));
  }
  _searchRequestCache = cacheManager.getCache(name + CACHE_NAME_SUFFIX);

  // Async prefetch executor service
  ExecutorServiceFactoryBean execBean = new ExecutorServiceFactoryBean();
  execBean.setNumberOfThreads(MAX_PREFETCH_CONCURRENCY);
  execBean.setStyle(ExecutorServiceFactoryBean.Style.CACHED);
  _executorService = execBean.getObjectCreating();
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:32,代码来源:EHCachingSearchCache.java

示例10: setupCacheSource

import net.sf.ehcache.config.CacheConfiguration; //导入依赖的package包/类
private void setupCacheSource(final boolean lazyReads, final int cacheSize, final int flushDelay) {
  InMemoryViewComputationCacheSource cache = new InMemoryViewComputationCacheSource(s_fudgeContext);
  ViewComputationCacheServer server = new ViewComputationCacheServer(cache);
  _serverSocket = new ServerSocketFudgeConnectionReceiver(cache.getFudgeContext(), server, Executors
      .newCachedThreadPool());
  _serverSocket.setLazyFudgeMsgReads(lazyReads);
  _serverSocket.start();
  _socket = new SocketFudgeConnection(cache.getFudgeContext());
  _socket.setFlushDelay(flushDelay);
  try {
    _socket.setInetAddress(InetAddress.getLocalHost());
  } catch (UnknownHostException e) {
    throw new OpenGammaRuntimeException("", e);
  }
  _socket.setPortNumber(_serverSocket.getPortNumber());

  RemoteCacheClient client = new RemoteCacheClient(_socket);
  Configuration configuration = new Configuration();
  CacheConfiguration cacheConfig = new CacheConfiguration();
  cacheConfig.setMaxElementsInMemory(cacheSize);
  configuration.setDefaultCacheConfiguration(cacheConfig);
  _cacheSource = new RemoteViewComputationCacheSource(client, new DefaultFudgeMessageStoreFactory(
      new InMemoryBinaryDataStoreFactory(), s_fudgeContext), _cacheManager);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:25,代码来源:ServerSocketRemoteViewComputationCacheTest.java

示例11: 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

示例12: 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

示例13: 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

示例14: getCacheManager

import net.sf.ehcache.config.CacheConfiguration; //导入依赖的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

示例15: 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


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