mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 12:25:50 +00:00
Polish contribution
Closes gh-229
This commit is contained in:
parent
443d35eae2
commit
75912a06c5
2 changed files with 12 additions and 10 deletions
2
pom.xml
2
pom.xml
|
@ -79,7 +79,7 @@
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- EhCache -->
|
<!-- caching -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.cache</groupId>
|
<groupId>javax.cache</groupId>
|
||||||
<artifactId>cache-api</artifactId>
|
<artifactId>cache-api</artifactId>
|
||||||
|
|
|
@ -3,9 +3,9 @@ package org.springframework.samples.petclinic.system;
|
||||||
import javax.cache.configuration.Configuration;
|
import javax.cache.configuration.Configuration;
|
||||||
import javax.cache.configuration.MutableConfiguration;
|
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.annotation.EnableCaching;
|
||||||
import org.springframework.cache.jcache.JCacheCacheManager;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,17 +14,19 @@ import org.springframework.context.annotation.Profile;
|
||||||
@org.springframework.context.annotation.Configuration
|
@org.springframework.context.annotation.Configuration
|
||||||
@EnableCaching
|
@EnableCaching
|
||||||
@Profile("production")
|
@Profile("production")
|
||||||
class CacheConfig implements CacheManagerCustomizer<JCacheCacheManager> {
|
class CacheConfig {
|
||||||
|
|
||||||
@Override
|
@Bean
|
||||||
public void customize(JCacheCacheManager cacheManager) {
|
public JCacheManagerCustomizer cacheManagerCustomizer() {
|
||||||
Configuration<Object, Object> cacheConfiguration = createCacheConfiguration();
|
return cm -> {
|
||||||
cacheManager.getCacheManager().createCache("vets", cacheConfiguration);
|
Configuration<Object, Object> cacheConfiguration = createCacheConfiguration();
|
||||||
|
cm.createCache("vets", cacheConfiguration);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private Configuration<Object, Object> createCacheConfiguration() {
|
private Configuration<Object, Object> createCacheConfiguration() {
|
||||||
// Create a cache using infinite heap. A real application will want to use an implementation dependent
|
// Create a cache using infinite heap. A real application will want to use an
|
||||||
// configuration that will better fit your needs
|
// implementation dependent configuration that will better fit your needs
|
||||||
return new MutableConfiguration<>().setStatisticsEnabled(true);
|
return new MutableConfiguration<>().setStatisticsEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue