Java Code Examples for net.sf.ehcache.config.CacheConfiguration#setMaxElementsInMemory()
The following examples show how to use
net.sf.ehcache.config.CacheConfiguration#setMaxElementsInMemory() .
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: DaoSpringModuleConfig.java From herd with Apache License 2.0 | 6 votes |
/** * 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); }
Example 2
Source File: CacheService.java From lutece-core with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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; }
Example 3
Source File: EhCacheRegionFactory.java From webdsl with Apache License 2.0 | 4 votes |
protected void overrideCacheConfiguration(Properties properties, CacheConfiguration cacheConfig, String cacheName) { String cachePrefix = NET_SF_EHCACHE_REGION_PREFIX + cacheName + "."; if(properties.get(cachePrefix + "maxElementsInMemory") != null) { int maxElementsInMemory = Integer.parseInt((String)properties.get(cachePrefix + "maxElementsInMemory")); cacheConfig.setMaxElementsInMemory(maxElementsInMemory); } if(properties.get(cachePrefix + "eternal") != null) { boolean eternal = Boolean.parseBoolean((String)properties.get(cachePrefix + "eternal")); cacheConfig.setEternal(eternal); } if(properties.get(cachePrefix + "timeToIdleSeconds") != null) { long timeToIdleSeconds = Long.parseLong((String)properties.get(cachePrefix + "timeToIdleSeconds")); cacheConfig.setTimeToIdleSeconds(timeToIdleSeconds); } if(properties.get(cachePrefix + "timeToLiveSeconds") != null) { long timeToLiveSeconds = Long.parseLong((String)properties.get(cachePrefix + "timeToLiveSeconds")); cacheConfig.setTimeToLiveSeconds(timeToLiveSeconds); } if(properties.get(cachePrefix + "overflowToDisk") != null) { boolean overflowToDisk = Boolean.parseBoolean((String)properties.get(cachePrefix + "overflowToDisk")); cacheConfig.setOverflowToDisk(overflowToDisk); } if(properties.get(cachePrefix + "maxElementsOnDisk") != null){ int maxElementsOnDisk = Integer.parseInt((String)properties.get(cachePrefix + "maxElementsOnDisk")); cacheConfig.setMaxElementsOnDisk(maxElementsOnDisk); } if(properties.get(cachePrefix + "diskPersistent") != null){ boolean diskPersistent = Boolean.parseBoolean((String)properties.get(cachePrefix + "diskPersistent")); cacheConfig.setDiskPersistent(diskPersistent); } if(properties.get(cachePrefix + "diskExpiryThreadIntervalSeconds") != null) { long diskExpiryThreadIntervalSeconds = Long.parseLong((String)properties.get(cachePrefix + "diskExpiryThreadIntervalSeconds")); cacheConfig.setDiskExpiryThreadIntervalSeconds(diskExpiryThreadIntervalSeconds); } if(properties.get(cachePrefix + "diskExpiryThreadIntervalSeconds") != null) { String memoryStoreEvictionPolicy = (String) properties.get(cachePrefix + "memoryStoreEvictionPolicy"); cacheConfig.setMemoryStoreEvictionPolicy(memoryStoreEvictionPolicy); } }