Search in sources :

Example 61 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project cloudbreak by hortonworks.

the class ResourceDefinitionCache method cacheConfiguration.

@Override
public CacheConfiguration cacheConfiguration() {
    CacheConfiguration cacheConfiguration = new CacheConfiguration();
    cacheConfiguration.setName("resourceDefinitionCache");
    cacheConfiguration.setMemoryStoreEvictionPolicy("LRU");
    cacheConfiguration.setMaxEntriesLocalHeap(MAX_ENTRIES);
    return cacheConfiguration;
}
Also used : CacheConfiguration(net.sf.ehcache.config.CacheConfiguration)

Example 62 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project onebusaway-application-modules by camsys.

the class EhCacheFactoryBean method createCache.

/**
 * Create a raw Cache object based on the configuration of this FactoryBean.
 */
private Cache createCache() {
    CacheConfiguration config = new CacheConfiguration(this.cacheName, this.maxElementsInMemory);
    config.setMemoryStoreEvictionPolicyFromObject(this.memoryStoreEvictionPolicy);
    config.setEternal(this.eternal);
    config.setTimeToLiveSeconds(this.timeToLive);
    config.setTimeToIdleSeconds(this.timeToIdle);
    PersistenceConfiguration pc = new PersistenceConfiguration();
    if (this.diskPersistent)
        pc.strategy(PersistenceConfiguration.Strategy.LOCALRESTARTABLE);
    else if (this.overflowToDisk)
        pc.strategy(PersistenceConfiguration.Strategy.LOCALTEMPSWAP);
    else
        pc.strategy(PersistenceConfiguration.Strategy.NONE);
    config.setDiskExpiryThreadIntervalSeconds(this.diskExpiryThreadIntervalSeconds);
    config.setMaxElementsOnDisk(this.maxElementsOnDisk);
    if (this.terracottaClustered) {
        TerracottaConfiguration tcConfig = new TerracottaConfiguration();
        tcConfig.setClustered(true);
        config.terracotta(tcConfig);
    }
    return new Cache(config);
}
Also used : PersistenceConfiguration(net.sf.ehcache.config.PersistenceConfiguration) TerracottaConfiguration(net.sf.ehcache.config.TerracottaConfiguration) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) SelfPopulatingCache(net.sf.ehcache.constructs.blocking.SelfPopulatingCache) BlockingCache(net.sf.ehcache.constructs.blocking.BlockingCache) UpdatingSelfPopulatingCache(net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache) Cache(net.sf.ehcache.Cache)

Example 63 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project LogHub by fbacchella.

the class NettyNameResolver method configure.

@Override
public boolean configure(Properties properties) {
    DnsNameResolverBuilder builder = new DnsNameResolverBuilder(evg.next()).queryTimeoutMillis(Math.max(timeout - 1, 1) * 1000).channelType(NioDatagramChannel.class);
    try {
        if (getResolver() != null) {
            InetSocketAddress resolverAddr = new InetSocketAddress(InetAddress.getByName(getResolver()), 53);
            builder = builder.nameServerProvider(new SingletonDnsServerAddressStreamProvider(resolverAddr));
        }
    } catch (UnknownHostException e) {
        logger.error("Unknown resolver '{}': {}", getResolver(), e.getMessage());
        return false;
    }
    resolver = builder.build();
    CacheConfiguration config = properties.getDefaultCacheConfig("NameResolver", this).eternal(false).maxEntriesLocalHeap(cacheSize);
    hostCache = properties.getCache(config);
    return super.configure(properties);
}
Also used : SingletonDnsServerAddressStreamProvider(io.netty.resolver.dns.SingletonDnsServerAddressStreamProvider) DnsNameResolverBuilder(io.netty.resolver.dns.DnsNameResolverBuilder) UnknownHostException(java.net.UnknownHostException) InetSocketAddress(java.net.InetSocketAddress) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration)

Example 64 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project gravitee-gateway by gravitee-io.

the class ApiKeysCacheConfiguration method cache.

@Bean
public Cache cache() {
    CacheManager cacheManager = cacheManager();
    Cache apiKeyCache = cacheManager.getCache(API_KEY_CACHE_NAME);
    if (apiKeyCache == null) {
        LOGGER.warn("EHCache cache for apikey not found. Fallback to default EHCache configuration");
        CacheConfiguration cacheConfiguration = new CacheConfiguration(API_KEY_CACHE_NAME, 1000);
        cacheManager.addCache(new Cache(cacheConfiguration));
    }
    return cacheManager.getCache(API_KEY_CACHE_NAME);
}
Also used : CacheManager(net.sf.ehcache.CacheManager) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Cache(net.sf.ehcache.Cache) Bean(org.springframework.context.annotation.Bean)

Example 65 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project qi4j-sdk by Qi4j.

the class EhCachePoolMixin method createNewCache.

private <T> EhCacheImpl<T> createNewCache(String cacheId, Class<T> valueType) {
    CacheConfiguration cc = createCacheConfiguration(cacheId);
    // TODO: We also need all the other Configurations that are possible, like cacheLoaderFactoryConfiguration
    net.sf.ehcache.Cache cache = new net.sf.ehcache.Cache(cc);
    cacheManager.addCache(cache);
    return new EhCacheImpl<T>(cacheId, cache, valueType);
}
Also used : CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Cache(org.qi4j.spi.cache.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