當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。