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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations