Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
broken-petclinic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Smart
broken-petclinic
Commits
893a18f5
Commit
893a18f5
authored
6 years ago
by
Stephane Nicoll
Browse files
Options
Downloads
Patches
Plain Diff
Polish "Clarify cache configuration"
Closes gh-335
parent
22ff3985
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/springframework/samples/petclinic/system/CacheConfiguration.java
+9
-33
9 additions, 33 deletions
...ramework/samples/petclinic/system/CacheConfiguration.java
with
9 additions
and
33 deletions
src/main/java/org/springframework/samples/petclinic/system/CacheConfiguration.java
+
9
−
33
View file @
893a18f5
package
org.springframework.samples.petclinic.system
;
package
org.springframework.samples.petclinic.system
;
import
javax.cache.configuration.MutableConfiguration
;
import
org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer
;
import
org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
javax.cache.configuration.MutableConfiguration
;
/**
/**
* Cache configuration intended for caches providing the JCache API. This configuration
* Cache configuration intended for caches providing the JCache API. This configuration creates the used cache for the
* creates the used cache for the application and enables statistics that
* application and enables statistics that become accessible via JMX.
* become accessible via JMX.
*
* <p>This is a minimal configuration that makes use of the JCache API to enable
* caching with any JCache implementation out of the box. The utilized JCache implementation
* is specified by the dependency in the {@code pom.xml}.
*
* <p>If the used cache implementation is configured via its specific and non standard mechanism,
* this example configuration might be redundant and can be removed or replaced by
* a programmatic configuration via the implementation specific methods.
*
* <p>In case no programmatic cache configuration is needed for the selected caching
* implementation this configuration class can be removed and the {@link EnableCaching}
* annotation can be put on the application class.
*
* @author Jens Wilke
*/
*/
@Configuration
@Configuration
@EnableCaching
@EnableCaching
class
CacheConfiguration
{
class
CacheConfiguration
{
/**
* A customizer that creates the the cache used by the application.
* This implies that the cache is not existent before the application start and the
* cache must be created. This is the default behavior of a JCache implemenation, in case
* no additional configuration is present and typically will create a transient in memory cache.
* If a persistent cache implementation is used, creating the cache on startup
* may lead to a failure, when the cache was created before. If the cache life time
* is controlled separately, the call of {@code createCache} must be removed.
*/
@Bean
@Bean
public
JCacheManagerCustomizer
petclinicCacheConfigurationCustomizer
()
{
public
JCacheManagerCustomizer
petclinicCacheConfigurationCustomizer
()
{
return
cm
->
{
return
cm
->
{
...
@@ -47,11 +23,11 @@ class CacheConfiguration {
...
@@ -47,11 +23,11 @@ class CacheConfiguration {
}
}
/**
/**
*
E
nable statistics via the JCache programmatic configuration API.
*
Create a simple configuration that e
nable statistics via the JCache programmatic configuration API.
*
Within the configuration object that is provided by the JCache API standard, there is only
*
<p>
*
a very limited set of configuration options. The really relevant configuration options
*
Within the configuration object that is provided by the JCache API standard, there is only a very limited set of
*
(like the size limit) must be set via a configuration mechanism that is provided by the
*
configuration options. The really relevant configuration options (like the size limit) must be set via a
* selected JCache implementation.
*
configuration mechanism that is provided by the
selected JCache implementation.
*/
*/
private
javax
.
cache
.
configuration
.
Configuration
<
Object
,
Object
>
cacheConfiguration
()
{
private
javax
.
cache
.
configuration
.
Configuration
<
Object
,
Object
>
cacheConfiguration
()
{
return
new
MutableConfiguration
<>().
setStatisticsEnabled
(
true
);
return
new
MutableConfiguration
<>().
setStatisticsEnabled
(
true
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment