I'm trying to use Ehcache manager in my application. I would like to setup it without xml configuration. I have next dependencies:
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>5.1.1.RELEASE</version>
</dependency>
I have such CacheManager bean:
@Bean
public org.springframework.cache.CacheManager cacheManager() {
org.ehcache.CacheManager mainPageCache = CacheManagerBuilder
.newCacheManagerBuilder()
.withCache("mainPageCache", CacheConfigurationBuilder
.newCacheConfigurationBuilder(
Pageable.class,
Collection.class,
ResourcePoolsBuilder.heap(10))
.withExpiry(ExpiryPolicyBuilder
.timeToLiveExpiration(Duration
.of(10, ChronoUnit.SECONDS))))
.build(true);
// ...
}
Is it possible to convert Ehcache CacheManager to Spring CacheManager?
I think there should be something like: return new JCacheCacheManager(/*some code*/);