Search in sources :

Example 46 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project cxf by apache.

the class EHCacheUtil method getCacheConfiguration.

public static CacheConfiguration getCacheConfiguration(String key, CacheManager cacheManager) {
    CacheConfiguration cc = cacheManager.getConfiguration().getCacheConfigurations().get(key);
    if (cc == null && key.contains("-")) {
        cc = cacheManager.getConfiguration().getCacheConfigurations().get(key.substring(0, key.lastIndexOf('-') - 1));
    }
    if (cc == null) {
        cc = cacheManager.getConfiguration().getDefaultCacheConfiguration();
    }
    if (cc == null) {
        cc = new CacheConfiguration();
    } else {
        cc = cc.clone();
    }
    cc.setName(key);
    return cc;
}
Also used : CacheConfiguration(net.sf.ehcache.config.CacheConfiguration)

Example 47 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project cxf by apache.

the class EHCacheUtil method getCacheConfiguration.

public static CacheConfiguration getCacheConfiguration(String key, CacheManager cacheManager) {
    CacheConfiguration cc = cacheManager.getConfiguration().getCacheConfigurations().get(key);
    if (cc == null && key.contains("-")) {
        cc = cacheManager.getConfiguration().getCacheConfigurations().get(key.substring(0, key.lastIndexOf('-') - 1));
    }
    if (cc == null) {
        cc = cacheManager.getConfiguration().getDefaultCacheConfiguration();
    }
    if (cc == null) {
        cc = new CacheConfiguration();
    } else {
        cc = cc.clone();
    }
    cc.setName(key);
    return cc;
}
Also used : CacheConfiguration(net.sf.ehcache.config.CacheConfiguration)

Example 48 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project ORCID-Source by ORCID.

the class WorksCacheManagerImpl method init.

@PostConstruct
private void init() {
    CacheConfiguration config1 = groupedWorksCache.getCacheConfiguration();
    groupedWorksCacheTTI = config1.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config1.getTimeToIdleSeconds()) : DEFAULT_TTI;
    groupedWorksCacheTTL = config1.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config1.getTimeToLiveSeconds()) : DEFAULT_TTL;
}
Also used : CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) PostConstruct(javax.annotation.PostConstruct)

Example 49 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project herd by FINRAOS.

the class DaoSpringModuleConfig method ehCacheManager.

/**
 * 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);
}
Also used : CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) DatabaseConfiguration(org.apache.commons.configuration.DatabaseConfiguration) Configuration(org.springframework.context.annotation.Configuration) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 50 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project openmrs-core by openmrs.

the class CachePropertiesUtil method createCacheConfiguration.

private static CacheConfiguration createCacheConfiguration(OpenmrsCacheConfiguration openmrsCacheConfiguration) {
    CacheConfiguration cacheConfiguration = new CacheConfiguration();
    openmrsCacheConfiguration.getAllKeys().forEach(key -> {
        try {
            BeanUtils.setProperty(cacheConfiguration, key, openmrsCacheConfiguration.getProperty(key));
        } catch (IllegalAccessException | InvocationTargetException e) {
            throw new IllegalStateException(e);
        }
    });
    return cacheConfiguration;
}
Also used : CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) InvocationTargetException(java.lang.reflect.InvocationTargetException)

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