Я пытаюсь использовать диспетчер Ehcache в своем приложении. Я хотел бы настроить его без конфигурации xml. У меня есть следующие зависимости:
<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>
У меня есть такой компонент CacheManager:
@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);
// ...
}
Можно ли преобразовать Ehcache CacheManager в Spring CacheManager? Я думаю, что должно быть что-то вроде: return new JCacheCacheManager(/*some code*/);