org.springframework.cache.concurrent.ConcurrentMapCacheManager Java Examples

The following examples show how to use org.springframework.cache.concurrent.ConcurrentMapCacheManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoadBalancerCacheAutoConfigurationTests.java    From spring-cloud-commons with Apache License 2.0 6 votes vote down vote up
@Test
void defaultLoadBalancerCacheShouldNotOverrideExistingCacheManager() {
	ApplicationContextRunner contextRunner = noCaffeineRunner()
			.withUserConfiguration(TestConfiguration.class);

	contextRunner.run(context -> {
		assertThat(context.getBeansOfType(CacheManager.class)).hasSize(2);
		assertThat(context.getBean("cacheManager"))
				.isInstanceOf(ConcurrentMapCacheManager.class);
		assertThat(((CacheManager) context.getBean("cacheManager")).getCacheNames())
				.isEmpty();
		assertThat(((CacheManager) context.getBean("defaultLoadBalancerCacheManager"))
				.getCacheNames()).hasSize(1);
		assertThat(((CacheManager) context.getBean("defaultLoadBalancerCacheManager"))
				.getCacheNames()).contains("CachingServiceInstanceListSupplierCache");
	});

}
 
Example #2
Source File: CachingConfiguration.java    From microservices-springboot with MIT License 5 votes vote down vote up
@Bean
@Override
public CacheManager cacheManager() {

    return new ConcurrentMapCacheManager() {

        @Override
        protected Cache createConcurrentMapCache(final String name) {
            return new ConcurrentMapCache(name, CacheBuilder.newBuilder()
                    .expireAfterWrite(30, TimeUnit.MINUTES)
                    .maximumSize(100).build().asMap(), false);
        }
    };
}
 
Example #3
Source File: MemcachedAutoConfigurationIT.java    From memcached-spring-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void whenCacheTypeIsSimpleThenSimpleCacheLoaded() {
    loadContext(CacheConfiguration.class, "spring.cache.type=simple");

    CacheManager cacheManager = this.applicationContext.getBean(CacheManager.class);

    assertThat(cacheManager).isInstanceOf(ConcurrentMapCacheManager.class);
}
 
Example #4
Source File: CachingTypeConverterTest.java    From conf4j with MIT License 5 votes vote down vote up
@Bean(name = Conf4jSpringConstants.CONF4J_TYPE_CONVERTER)
public TypeConverter<Object> typeConverter() {
    CachingTypeConverter<Object> cachingTypeConverter = new CachingTypeConverter<>();
    cachingTypeConverter.setTypeConverter(DefaultTypeConverters.getDefaultTypeConverter());
    cachingTypeConverter.setCacheManager(new ConcurrentMapCacheManager());
    return cachingTypeConverter;
}
 
Example #5
Source File: MemcachedAutoConfigurationIT.java    From memcached-spring-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void whenUsingCustomCacheManagerThenMemcachedCustomCacheManagerLoaded() {
    loadContext(CacheWithCustomCacheManagerConfiguration.class);

    CacheManager cacheManager = this.applicationContext.getBean(CacheManager.class);

    assertThat(cacheManager).isInstanceOf(ConcurrentMapCacheManager.class);
}
 
Example #6
Source File: LoadBalancerCacheAutoConfigurationTests.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
@Test
void shouldNotInstantiateDefaultLoadBalancerCacheIfDisabled() {
	ApplicationContextRunner contextRunner = noCaffeineRunner()
			.withPropertyValues("spring.cloud.loadbalancer.cache.enabled=false")
			.withUserConfiguration(TestConfiguration.class);

	contextRunner.run(context -> {
		assertThat(context.getBeansOfType(CacheManager.class)).hasSize(1);
		assertThat(context.getBean("cacheManager"))
				.isInstanceOf(ConcurrentMapCacheManager.class);
		assertThat(((CacheManager) context.getBean("cacheManager")).getCacheNames())
				.isEmpty();
	});
}
 
Example #7
Source File: MemcachedAutoConfigurationTest.java    From memcached-spring-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void whenCacheTypeIsSimpleThenSimpleCacheLoaded() {
    loadContext(CacheConfiguration.class, "spring.cache.type=simple");

    CacheManager cacheManager = this.applicationContext.getBean(CacheManager.class);

    assertThat(cacheManager).isInstanceOf(ConcurrentMapCacheManager.class);
}
 
Example #8
Source File: MemcachedAutoConfigurationTest.java    From memcached-spring-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void whenUsingCustomCacheManagerThenMemcachedCustomCacheManagerLoaded() {
    loadContext(CacheWithCustomCacheManagerConfiguration.class);

    CacheManager cacheManager = this.applicationContext.getBean(CacheManager.class);

    assertThat(cacheManager).isInstanceOf(ConcurrentMapCacheManager.class);
}
 
Example #9
Source File: JCacheKeyGeneratorTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Bean
@Override
public CacheManager cacheManager() {
	return new ConcurrentMapCacheManager();
}
 
Example #10
Source File: MemcachedAutoConfigurationIT.java    From memcached-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean
public CacheManager cacheManager() {
    return new ConcurrentMapCacheManager();
}
 
Example #11
Source File: CacheReproTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public MyCacheResolver() {
	super(new ConcurrentMapCacheManager());
}
 
Example #12
Source File: CacheReproTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Bean
public CacheManager cacheManager() {
	return new ConcurrentMapCacheManager();
}
 
Example #13
Source File: CacheReproTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Bean
public CacheManager cacheManager() {
	return new ConcurrentMapCacheManager();
}
 
Example #14
Source File: ExpressionCachingIntegrationTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
@Bean
public CacheManager cacheManager() {
	return new ConcurrentMapCacheManager();
}
 
Example #15
Source File: CachePutEvaluationTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Bean
@Override
public CacheManager cacheManager() {
	return new ConcurrentMapCacheManager();
}
 
Example #16
Source File: OrderApplication.java    From Mastering-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public CacheManager cacheManager() {
	return new ConcurrentMapCacheManager("customers");
}
 
Example #17
Source File: CustomerApplication.java    From Mastering-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public CacheManager cacheManager() {
	return new ConcurrentMapCacheManager("accounts");
}
 
Example #18
Source File: OrderApplication.java    From Mastering-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public CacheManager cacheManager() {
	return new ConcurrentMapCacheManager("customers");
}
 
Example #19
Source File: CustomerApplication.java    From Mastering-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public CacheManager cacheManager() {
	return new ConcurrentMapCacheManager("accounts");
}
 
Example #20
Source File: JCacheJavaConfigTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
@Bean
public CacheResolver cacheResolver() {
	return new NamedCacheResolver(new ConcurrentMapCacheManager(), "default");
}
 
Example #21
Source File: BaseConfig.java    From benchmarks with Apache License 2.0 4 votes vote down vote up
@Bean
public CacheManager cacheManager() {
	return new ConcurrentMapCacheManager();
}
 
Example #22
Source File: MemcachedAutoConfigurationTest.java    From memcached-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean
public CacheManager cacheManager() {
    return new ConcurrentMapCacheManager();
}
 
Example #23
Source File: IssueTrackerConfiguration.java    From spring-data-dev-tools with Apache License 2.0 4 votes vote down vote up
@Bean
CacheManager cacheManager() {
	return new ConcurrentMapCacheManager();
}
 
Example #24
Source File: Application.java    From sparql-playground with GNU General Public License v2.0 4 votes vote down vote up
@Bean
public CacheManager cacheManager() {
	return new ConcurrentMapCacheManager("asset", "queries", "faqs", "page", "page-tree");
}
 
Example #25
Source File: MvcConfiguration.java    From reference-ccda-validator with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Bean
public CacheManager cacheManager() {
    return new ConcurrentMapCacheManager("messagetypeValidationObjectivesAndReferenceFilesMap");
}
 
Example #26
Source File: ConcurrentMapCacheManagerServer.java    From POC with Apache License 2.0 4 votes vote down vote up
@Bean
public CacheManager cacheManager() {
	return new ConcurrentMapCacheManager("books");
}
 
Example #27
Source File: SimpleCacheCustomizer.java    From tutorials with MIT License 4 votes vote down vote up
@Override
public void customize(ConcurrentMapCacheManager cacheManager) {
    LOGGER.info("Customizing Cache Manager");
    cacheManager.setCacheNames(asList(USERS_CACHE, TRANSACTIONS_CACHE));
}
 
Example #28
Source File: MultipleCacheManagerConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public CacheManager alternateCacheManager() {
    return new ConcurrentMapCacheManager("customerOrders", "orderprice");
}
 
Example #29
Source File: BookRepositoryCachingIntegrationTest.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public CacheManager cacheManager() {
    return new ConcurrentMapCacheManager("books");
}
 
Example #30
Source File: ConcurrentMapCacheConfig.java    From spring4-sandbox with Apache License 2.0 4 votes vote down vote up
@Override
@Bean
public CacheManager cacheManager() {
	return new ConcurrentMapCacheManager();
}