use of org.ehcache.jsr107.EhcacheCachingProvider in project oncotree by cBioPortal.
the class OncoTreeAppConfig method cachingProvider.
@Bean
public CachingProvider cachingProvider() throws Exception {
logger.info("cachingProvider() called");
CachingProvider cachingProvider = new EhcacheCachingProvider();
return cachingProvider;
}
use of org.ehcache.jsr107.EhcacheCachingProvider in project cas by apereo.
the class Ehcache3TicketRegistryConfiguration method ehcache3TicketCacheManager.
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "ehcache3TicketCacheManager")
public CacheManager ehcache3TicketCacheManager(final ConfigurableApplicationContext applicationContext, @Qualifier("ehcache3CacheManagerConfiguration") final ServiceCreationConfiguration ehcache3CacheManagerConfiguration, final CasConfigurationProperties casProperties) {
return BeanSupplier.of(CacheManager.class).when(CONDITION.given(applicationContext.getEnvironment())).supply(() -> {
val ehcacheProperties = casProperties.getTicket().getRegistry().getEhcache3();
val ehcacheProvider = (EhcacheCachingProvider) Caching.getCachingProvider(EhcacheCachingProvider.class.getName());
val statisticsAllEnabled = ehcacheProperties.isEnableStatistics() ? ConfigurationElementState.ENABLED : ConfigurationElementState.DISABLED;
val managementEnabled = ehcacheProperties.isEnableManagement() ? ConfigurationElementState.ENABLED : ConfigurationElementState.DISABLED;
val jsr107Config = new Jsr107Configuration(null, new HashMap<>(), false, managementEnabled, statisticsAllEnabled);
val configuration = new DefaultConfiguration(ehcacheProvider.getDefaultClassLoader(), ehcache3CacheManagerConfiguration, jsr107Config);
return ehcacheProvider.getCacheManager(ehcacheProvider.getDefaultURI(), configuration);
}).otherwiseProxy().get();
}
use of org.ehcache.jsr107.EhcacheCachingProvider in project CzechIdMng by bcvsolutions.
the class ClusteredEhCacheConfiguration method ehCacheManager.
/**
* Defines clustered {@link CacheManager} using Terracotta server.
*
* @param terracotaUrl a list of IP addresses with ports (IP_ADDR:PORT)
* @param terracotaResourceName name of server resource to connect
* @param terracotaResourcePoolName name od server resource pool name
* @param terracotaResourcePoolSize size of server resource pool in MB
* @param idMCacheConfigurations a list of {@link IdMCacheConfiguration} defined in container
* @return CacheManager with distributed capabilities
*/
@Bean
@Qualifier("jCacheManager")
@ConditionalOnProperty(value = TERRACOTA_URL_PROPERTY)
@ConditionalOnMissingBean
public CacheManager ehCacheManager(@Value("${" + TERRACOTA_URL_PROPERTY + "}") String terracotaUrl, @Value("${" + TERRACOTA_RESOURCE_NAME_PROPERTY + "}") String terracotaResourceName, @Value("${" + TERRACOTA_RESOURCE_POOL_NAME_PROPERTY + "}") String terracotaResourcePoolName, @Value("${" + TERRACOTA_RESOURCE_POOL_SIZE_PROPERTY + "}") int terracotaResourcePoolSize, @Autowired List<IdMCacheConfiguration> idMCacheConfigurations) {
CacheManagerBuilder<PersistentCacheManager> clusteredCacheManagerBuilder = CacheManagerBuilder.newCacheManagerBuilder().with(ClusteringServiceConfigurationBuilder.cluster(parseServerAddresses(terracotaUrl), "default").autoCreate(server -> server.defaultServerResource(terracotaResourceName).resourcePool(terracotaResourcePoolName, terracotaResourcePoolSize, MemoryUnit.MB, terracotaResourceName))).withSerializer(CacheObjectWrapper.class, CacheWrapperSerializer.class).withSerializer(SerializableCacheObjectWrapper.class, SerializableCacheWrapperSerializer.class);
PersistentCacheManager cacheManager = clusteredCacheManagerBuilder.build(true);
// create caches using IdMCacheConfiguration instances
if (!CollectionUtils.isEmpty(idMCacheConfigurations)) {
for (IdMCacheConfiguration config : idMCacheConfigurations) {
cacheManager.createCache(config.getCacheName(), toConcreteConfiguration(config, terracotaResourcePoolName));
}
}
// get CacheManager (Jcache) with above updated configuration
final EhcacheCachingProvider ehcacheCachingProvider = (EhcacheCachingProvider) Caching.getCachingProvider();
return ehcacheCachingProvider.getCacheManager(ehcacheCachingProvider.getDefaultURI(), cacheManager.getRuntimeConfiguration());
}
use of org.ehcache.jsr107.EhcacheCachingProvider in project CzechIdMng by bcvsolutions.
the class InMemoryEhCacheConfiguration method ehCacheManager.
/**
* Defines in-memory cache manager.
*
* @param idMCacheConfigurations {@link List} of {@link IdMCacheConfiguration} defined in container
* @return CacheManager with on-heap capabilities
*/
@Bean
@Qualifier("jCacheManager")
@ConditionalOnMissingBean
public CacheManager ehCacheManager(@Autowired List<IdMCacheConfiguration> idMCacheConfigurations) {
CacheManagerBuilder<?> localCacheManagerBuilder = CacheManagerBuilder.newCacheManagerBuilder();
if (!CollectionUtils.isEmpty(idMCacheConfigurations)) {
for (IdMCacheConfiguration config : idMCacheConfigurations) {
localCacheManagerBuilder = localCacheManagerBuilder.withCache(config.getCacheName(), toConcreteConfiguration(config));
}
}
// get CacheManager (Jcache) with above updated configuration
final EhcacheCachingProvider ehcacheCachingProvider = (EhcacheCachingProvider) Caching.getCachingProvider();
return ehcacheCachingProvider.getCacheManager(ehcacheCachingProvider.getDefaultURI(), localCacheManagerBuilder.build(true).getRuntimeConfiguration());
}
use of org.ehcache.jsr107.EhcacheCachingProvider in project toy by gmoon92.
the class EhCacheConfig method createManager.
@Bean
public CacheManager createManager() {
CachingProvider provider = new EhcacheCachingProvider();
CacheManager manager = provider.getCacheManager();
// config
// MutableConfiguration configuration = new MutableConfiguration<Long, Member>()
MutableConfiguration configuration = new MutableConfiguration().setStoreByValue(false).setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(Duration.ONE_MINUTE));
// listener config
MutableCacheEntryListenerConfiguration listenerConfiguration = new MutableCacheEntryListenerConfiguration(FactoryBuilder.factoryOf(CacheEventLoggerListener.class), null, true, true);
configuration.addCacheEntryListenerConfiguration(listenerConfiguration);
// add cache
manager.createCache(MEMBER_ALL, configuration);
manager.createCache(MEMBER_FIND_BY_ID, configuration);
return manager;
}
Aggregations