use of net.sf.ehcache.config.CacheConfiguration in project ORCID-Source by ORCID.
the class OrcidEhCacheFactoryBean method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
Ehcache existingCache = cacheManager.getEhcache(cacheName);
String diskStorePath = cacheManager.getConfiguration().getDiskStoreConfiguration().getPath();
LOGGER.debug("Cache manager disk store path = " + diskStorePath);
if (existingCache == null) {
CacheConfiguration config = createConfig();
if (cacheEntryFactory != null) {
this.cache = new SelfPopulatingCache(new Cache(config), cacheEntryFactory);
} else {
this.cache = new Cache(config);
}
cacheManager.addCache(this.cache);
} else {
this.cache = existingCache;
}
}
use of net.sf.ehcache.config.CacheConfiguration in project ORCID-Source by ORCID.
the class OrcidEhCacheFactoryBean method createConfig.
private CacheConfiguration createConfig() {
CacheConfiguration config = new CacheConfiguration();
config.setName(this.cacheName);
config.setMaxEntriesLocalHeap(this.maxElementsInMemory);
config.setMaxElementsOnDisk(this.maxElementsOnDisk);
config.setMaxBytesLocalDisk(this.maxBytesLocalDisk);
config.setTimeToLiveSeconds(this.timeToLiveSeconds);
config.setTimeToIdleSeconds(this.timeToIdleSeconds);
config.setCopyOnRead(this.copyOnRead);
config.setCopyOnWrite(this.copyOnWrite);
config.persistence(new PersistenceConfiguration().strategy(this.strategy));
return config;
}
use of net.sf.ehcache.config.CacheConfiguration in project spring-framework by spring-projects.
the class EhCacheCacheManagerTests method setup.
@Before
public void setup() {
nativeCacheManager = new CacheManager(new Configuration().name("EhCacheCacheManagerTests").defaultCache(new CacheConfiguration("default", 100)));
addNativeCache(CACHE_NAME);
cacheManager = new EhCacheCacheManager(nativeCacheManager);
cacheManager.setTransactionAware(false);
cacheManager.afterPropertiesSet();
transactionalCacheManager = new EhCacheCacheManager(nativeCacheManager);
transactionalCacheManager.setTransactionAware(true);
transactionalCacheManager.afterPropertiesSet();
}
use of net.sf.ehcache.config.CacheConfiguration in project gocd by gocd.
the class GoCacheFactory method createCacheManager.
private CacheManager createCacheManager() throws UnsupportedEncodingException {
Configuration configuration = new Configuration();
configuration.setUpdateCheck(false);
configuration.addDiskStore(diskStore());
configuration.setDefaultCacheConfiguration(new CacheConfiguration("cache", 10000));
return new CacheManager(configuration);
}
use of net.sf.ehcache.config.CacheConfiguration in project cxf by apache.
the class EHCacheSPStateManager method createCaches.
private void createCaches(String configFile, Bus bus) {
if (bus == null) {
bus = BusFactory.getThreadDefaultBus(true);
}
URL configFileURL = null;
try {
configFileURL = ResourceUtils.getClasspathResourceURL(configFile, EHCacheSPStateManager.class, bus);
} catch (Exception ex) {
// ignore
}
if (configFileURL == null) {
cacheManager = EHCacheUtil.createCacheManager();
} else {
Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
if (bus != null) {
conf.setName(bus.getId());
DiskStoreConfiguration dsc = conf.getDiskStoreConfiguration();
if (dsc != null && "java.io.tmpdir".equals(dsc.getOriginalPath())) {
String path = conf.getDiskStoreConfiguration().getPath() + File.separator + bus.getId();
conf.getDiskStoreConfiguration().setPath(path);
}
}
cacheManager = EHCacheUtil.createCacheManager(conf);
}
CacheConfiguration requestCC = EHCacheUtil.getCacheConfiguration(REQUEST_CACHE_KEY, cacheManager);
Ehcache newCache = new Cache(requestCC);
requestCache = cacheManager.addCacheIfAbsent(newCache);
CacheConfiguration responseCC = EHCacheUtil.getCacheConfiguration(RESPONSE_CACHE_KEY, cacheManager);
newCache = new Cache(responseCC);
responseCache = cacheManager.addCacheIfAbsent(newCache);
}
Aggregations