Search in sources :

Example 6 with CacheManager

use of org.springframework.cache.CacheManager in project tutorials by eugenp.

the class CacheConfiguration method cacheManager.

@Bean
public CacheManager cacheManager(HazelcastInstance hazelcastInstance) {
    log.debug("Starting HazelcastCacheManager");
    CacheManager cacheManager = new com.hazelcast.spring.cache.HazelcastCacheManager(hazelcastInstance);
    return cacheManager;
}
Also used : CacheManager(org.springframework.cache.CacheManager)

Example 7 with CacheManager

use of org.springframework.cache.CacheManager in project cetc by DiscoverForever.

the class CacheConfiguration method cacheManager.

@Bean
public CacheManager cacheManager(HazelcastInstance hazelcastInstance) {
    log.debug("Starting HazelcastCacheManager");
    CacheManager cacheManager = new com.hazelcast.spring.cache.HazelcastCacheManager(hazelcastInstance);
    return cacheManager;
}
Also used : CacheManager(org.springframework.cache.CacheManager)

Example 8 with CacheManager

use of org.springframework.cache.CacheManager in project jhipster-sample-app-hazelcast by jhipster.

the class CacheConfiguration method cacheManager.

@Bean
public CacheManager cacheManager(HazelcastInstance hazelcastInstance) {
    log.debug("Starting HazelcastCacheManager");
    CacheManager cacheManager = new com.hazelcast.spring.cache.HazelcastCacheManager(hazelcastInstance);
    return cacheManager;
}
Also used : CacheManager(org.springframework.cache.CacheManager)

Example 9 with CacheManager

use of org.springframework.cache.CacheManager in project nextprot-api by calipho-sib.

the class GenerateSolrIndex method launch.

protected void launch(String[] args) {
    try {
        // System.setProperty("spring.profiles.active", "dev");
        System.setProperty("spring.profiles.active", "dev, cache");
        ctx = new ClassPathXmlApplicationContext("classpath:spring/commons-context.xml", "classpath:spring/core-context.xml");
        cacheManager = ctx.getBean(CacheManager.class);
        start(args);
    } finally {
        shutdown();
    }
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) EhCacheCacheManager(org.springframework.cache.ehcache.EhCacheCacheManager) CacheManager(org.springframework.cache.CacheManager)

Example 10 with CacheManager

use of org.springframework.cache.CacheManager in project spring-boot by spring-projects.

the class CacheAutoConfigurationTests method couchbaseCacheWithCouchbaseCacheManagerBuilderCustomizer.

@Test
void couchbaseCacheWithCouchbaseCacheManagerBuilderCustomizer() {
    this.contextRunner.withUserConfiguration(CouchbaseConfiguration.class).withPropertyValues("spring.cache.type=couchbase", "spring.cache.couchbase.expiration=15s").withBean(CouchbaseCacheManagerBuilderCustomizer.class, () -> (builder) -> builder.cacheDefaults(CouchbaseCacheConfiguration.defaultCacheConfig().entryExpiry(java.time.Duration.ofSeconds(10)))).run((context) -> {
        CouchbaseCacheManager cacheManager = getCacheManager(context, CouchbaseCacheManager.class);
        CouchbaseCacheConfiguration couchbaseCacheConfiguration = getDefaultCouchbaseCacheConfiguration(cacheManager);
        assertThat(couchbaseCacheConfiguration.getExpiry()).isEqualTo(java.time.Duration.ofSeconds(10));
    });
}
Also used : CaffeineCacheManager(org.springframework.cache.caffeine.CaffeineCacheManager) SimpleCacheManager(org.springframework.cache.support.SimpleCacheManager) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RedisCacheConfiguration(org.springframework.data.redis.cache.RedisCacheConfiguration) ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) BDDMockito.given(org.mockito.BDDMockito.given) MutableConfiguration(javax.cache.configuration.MutableConfiguration) MockCacheManager(org.springframework.boot.autoconfigure.cache.support.MockCachingProvider.MockCacheManager) Resource(org.springframework.core.io.Resource) CompleteConfiguration(javax.cache.configuration.CompleteConfiguration) Test(org.junit.jupiter.api.Test) BeanPostProcessor(org.springframework.beans.factory.config.BeanPostProcessor) Configuration(org.springframework.context.annotation.Configuration) List(java.util.List) CachingConfigurer(org.springframework.cache.annotation.CachingConfigurer) ConcurrentMapCache(org.springframework.cache.concurrent.ConcurrentMapCache) Hazelcast(com.hazelcast.core.Hazelcast) NoOpCacheManager(org.springframework.cache.support.NoOpCacheManager) Mockito.mock(org.mockito.Mockito.mock) CouchbaseCacheManager(org.springframework.data.couchbase.cache.CouchbaseCacheManager) Cache(org.springframework.cache.Cache) CouchbaseClientFactory(org.springframework.data.couchbase.CouchbaseClientFactory) ClassPathResource(org.springframework.core.io.ClassPathResource) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) CacheResolver(org.springframework.cache.interceptor.CacheResolver) ArrayList(java.util.ArrayList) HazelcastCacheManager(com.hazelcast.spring.cache.HazelcastCacheManager) BeanCreationException(org.springframework.beans.factory.BeanCreationException) CacheManager(org.springframework.cache.CacheManager) CaffeineCache(org.springframework.cache.caffeine.CaffeineCache) Duration(javax.cache.expiry.Duration) EnableCaching(org.springframework.cache.annotation.EnableCaching) CouchbaseCache(org.springframework.data.couchbase.cache.CouchbaseCache) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Caffeine(com.github.benmanes.caffeine.cache.Caffeine) CreatedExpiryPolicy(javax.cache.expiry.CreatedExpiryPolicy) AutoConfigurations(org.springframework.boot.autoconfigure.AutoConfigurations) Caching(javax.cache.Caching) Import(org.springframework.context.annotation.Import) RedisCacheManager(org.springframework.data.redis.cache.RedisCacheManager) ReflectionTestUtils(org.springframework.test.util.ReflectionTestUtils) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) CaffeineSpec(com.github.benmanes.caffeine.cache.CaffeineSpec) HazelcastAutoConfiguration(org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration) JCacheCacheManager(org.springframework.cache.jcache.JCacheCacheManager) MockCachingProvider(org.springframework.boot.autoconfigure.cache.support.MockCachingProvider) AssertableApplicationContext(org.springframework.boot.test.context.assertj.AssertableApplicationContext) Bean(org.springframework.context.annotation.Bean) CouchbaseCacheConfiguration(org.springframework.data.couchbase.cache.CouchbaseCacheConfiguration) Collections(java.util.Collections) ClassPathExclusions(org.springframework.boot.testsupport.classpath.ClassPathExclusions) CouchbaseCacheConfiguration(org.springframework.data.couchbase.cache.CouchbaseCacheConfiguration) CouchbaseCacheManager(org.springframework.data.couchbase.cache.CouchbaseCacheManager) Test(org.junit.jupiter.api.Test)

Aggregations

CacheManager (org.springframework.cache.CacheManager)28 Test (org.junit.jupiter.api.Test)12 ConcurrentMapCacheManager (org.springframework.cache.concurrent.ConcurrentMapCacheManager)10 SimpleCacheManager (org.springframework.cache.support.SimpleCacheManager)10 Cache (org.springframework.cache.Cache)8 LinkedHashMap (java.util.LinkedHashMap)5 HazelcastCacheManager (com.hazelcast.spring.cache.HazelcastCacheManager)4 CaffeineCacheManager (org.springframework.cache.caffeine.CaffeineCacheManager)4 EhCacheCacheManager (org.springframework.cache.ehcache.EhCacheCacheManager)4 NoOpCacheManager (org.springframework.cache.support.NoOpCacheManager)4 RedisCacheManager (org.springframework.data.redis.cache.RedisCacheManager)4 JCacheCacheManager (org.springframework.cache.jcache.JCacheCacheManager)3 CouchbaseCacheManager (com.couchbase.client.spring.cache.CouchbaseCacheManager)2 Caffeine (com.github.benmanes.caffeine.cache.Caffeine)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 SpringEmbeddedCacheManager (org.infinispan.spring.provider.SpringEmbeddedCacheManager)2 CacheEntry (org.springframework.boot.actuate.cache.CachesEndpoint.CacheEntry)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2