Search in sources :

Example 1 with CacheConfiguration

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;
    }
}
Also used : SelfPopulatingCache(net.sf.ehcache.constructs.blocking.SelfPopulatingCache) Ehcache(net.sf.ehcache.Ehcache) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) SelfPopulatingCache(net.sf.ehcache.constructs.blocking.SelfPopulatingCache) Cache(net.sf.ehcache.Cache)

Example 2 with CacheConfiguration

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;
}
Also used : PersistenceConfiguration(net.sf.ehcache.config.PersistenceConfiguration) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration)

Example 3 with CacheConfiguration

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();
}
Also used : CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Configuration(net.sf.ehcache.config.Configuration) CacheManager(net.sf.ehcache.CacheManager) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Before(org.junit.Before)

Example 4 with CacheConfiguration

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);
}
Also used : DiskStoreConfiguration(net.sf.ehcache.config.DiskStoreConfiguration) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Configuration(net.sf.ehcache.config.Configuration) CacheManager(net.sf.ehcache.CacheManager) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration)

Example 5 with CacheConfiguration

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);
}
Also used : DiskStoreConfiguration(net.sf.ehcache.config.DiskStoreConfiguration) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Configuration(net.sf.ehcache.config.Configuration) Ehcache(net.sf.ehcache.Ehcache) DiskStoreConfiguration(net.sf.ehcache.config.DiskStoreConfiguration) URL(java.net.URL) IOException(java.io.IOException) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Cache(net.sf.ehcache.Cache)

Aggregations

CacheConfiguration (net.sf.ehcache.config.CacheConfiguration)71 Cache (net.sf.ehcache.Cache)26 CacheManager (net.sf.ehcache.CacheManager)16 Ehcache (net.sf.ehcache.Ehcache)14 Configuration (net.sf.ehcache.config.Configuration)14 Element (net.sf.ehcache.Element)9 PersistenceConfiguration (net.sf.ehcache.config.PersistenceConfiguration)8 DiskStoreConfiguration (net.sf.ehcache.config.DiskStoreConfiguration)6 Test (org.junit.Test)6 Resource (org.springframework.core.io.Resource)6 IOException (java.io.IOException)5 Bean (org.springframework.context.annotation.Bean)5 CachedResource (org.apereo.portal.utils.cache.resource.CachedResource)4 CachingResourceLoaderImpl (org.apereo.portal.utils.cache.resource.CachingResourceLoaderImpl)4 LoadedResource (org.apereo.portal.utils.cache.resource.LoadedResource)4 ResourcesElementsProvider (org.jasig.resourceserver.utils.aggr.ResourcesElementsProvider)4 FileSystemResource (org.springframework.core.io.FileSystemResource)4 FileReader (java.io.FileReader)3 URL (java.net.URL)3 SelfPopulatingCache (net.sf.ehcache.constructs.blocking.SelfPopulatingCache)3