mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 12:15: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>
|
||||
</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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue