Skip to content
Snippets Groups Projects
Commit 75912a06 authored by Stephane Nicoll's avatar Stephane Nicoll
Browse files

Polish contribution

Closes gh-229
parent 443d35ea
No related branches found
No related tags found
No related merge requests found
......@@ -79,7 +79,7 @@
<scope>runtime</scope>
</dependency>
<!-- EhCache -->
<!-- caching -->
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
......
......@@ -3,9 +3,9 @@ package org.springframework.samples.petclinic.system;
import javax.cache.configuration.Configuration;
import javax.cache.configuration.MutableConfiguration;
import org.springframework.boot.autoconfigure.cache.CacheManagerCustomizer;
import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.jcache.JCacheCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;
/**
......@@ -14,17 +14,19 @@ import org.springframework.context.annotation.Profile;
@org.springframework.context.annotation.Configuration
@EnableCaching
@Profile("production")
class CacheConfig implements CacheManagerCustomizer<JCacheCacheManager> {
class CacheConfig {
@Override
public void customize(JCacheCacheManager cacheManager) {
Configuration<Object, Object> cacheConfiguration = createCacheConfiguration();
cacheManager.getCacheManager().createCache("vets", cacheConfiguration);
@Bean
public JCacheManagerCustomizer cacheManagerCustomizer() {
return cm -> {
Configuration<Object, Object> cacheConfiguration = createCacheConfiguration();
cm.createCache("vets", cacheConfiguration);
};
}
private Configuration<Object, Object> createCacheConfiguration() {
// Create a cache using infinite heap. A real application will want to use an implementation dependent
// configuration that will better fit your needs
// Create a cache using infinite heap. A real application will want to use an
// implementation dependent configuration that will better fit your needs
return new MutableConfiguration<>().setStatisticsEnabled(true);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment