@@ -15,8 +15,8 @@ abstraction is supported by many caching libraries, including:
15
15
* Generic provider based on `org.springframework.Cache` bean definition(s)
16
16
17
17
The sample defines a simple `CountryService` that caches countries by ISO code. When
18
- the application starts a client invokes the service with a random code every 500ms. You
19
- can look at the `/metrics` endpoint to review the cache statistics if your chosen
18
+ the application starts a client invokes the service with a random code every 500ms.
19
+ You can look at the `/metrics` endpoint to review the cache statistics if your chosen
20
20
caching provider is supported.
21
21
22
22
@@ -26,30 +26,31 @@ The sample uses Spring's cache annotation. If you want to use the JSR-107 annota
26
26
instead, simply add the `javax.cache:cache-api` dependency to the project. No further
27
27
configuration is necessary.
28
28
29
- NOTE: You can use the JSR-107 annotations with _any_ cache provider; a JSR-107 compliant
30
- cache provider is not necessary.
29
+ NOTE: You can use the JSR-107 annotations with _any_ cache provider; a JSR-107
30
+ compliant cache provider is not necessary.
31
31
32
32
33
33
34
34
== Using a different cache provider
35
35
Initially, the project does not define any caching library so the abstraction works
36
- on simple `ConcurrentHashMap`-based caches. You can try out your favorite caching library
37
- as explained below.
36
+ on simple `ConcurrentHashMap`-based caches. You can try out your favorite caching
37
+ library as explained below.
38
38
39
39
40
40
41
41
=== JCache (JSR-107)
42
- If you want to configure your cache infrastructure via the standard, you need a compliant
43
- implementation and the JSR-107 api. You first need to add `javax.cache:cache-api` to your
44
- project. Then you could try the following:
42
+ If you want to configure your cache infrastructure via the standard, you need a
43
+ compliant implementation and the JSR-107 api. You first need to add
44
+ `javax.cache:cache-api` to your project. Then you could try the following:
45
45
46
46
* `EhCache 3`: add `org.ehcache:ehcache`
47
47
* `Hazelcast`: add `com.hazelcast:hazelcast`
48
48
* `Infinispan`: add `org.infinispan:infinispan-jcache`
49
49
50
- TIP: Certain cache providers do not create a default cache on-the-fly if it does not exist
51
- so you might need to update the sample to create the caches on startup or specify the
52
- location to the provider-specific file via the `spring.cache.jcache.config` property.
50
+ TIP: Certain cache providers do not create a default cache on-the-fly if it does not
51
+ exist so you might need to update the sample to create the caches on startup or
52
+ specify the location to the provider-specific file via the
53
+ `spring.cache.jcache.config` property.
53
54
54
55
NOTE: Any other JSR-107 compliant provider is also supported but Spring Boot may not
55
56
offer a dependency management entry for it. You will have to add it with the version
@@ -59,39 +60,55 @@ of the library that you want to use.
59
60
60
61
=== EhCache 2.x
61
62
Simply add the `net.sf.ehcache:ehcache` dependency to the project. Since there is a
62
- default `ehcache.xml` configuration file at the root of the classpath, it is automatically
63
- used to configure the underlying `CacheManager`. Note that EhCache 3 uses a different
64
- format and doesn't default to `ehcache.xml` anymore. Check
65
- http://www.ehcache.org/documentation/3.0/xml.html[the documentation] for more details.
63
+ default `ehcache.xml` configuration file at the root of the classpath,
64
+ it is automatically used to configure the underlying `CacheManager`.
65
+ Note that EhCache 3 uses a different format and doesn't default to `ehcache.xml`
66
+ anymore. Check http://www.ehcache.org/documentation/3.0/xml.html[the documentation]
67
+ for more details.
68
+
69
+ TIP: Run sample cache application using EhCache with
70
+ `$mvn spring-boot:run -Pehcache2`.
66
71
67
72
68
73
69
74
=== Hazelcast
70
- Both `com.hazelcast:hazelcast` and `com.hazelcast:hazelcast-spring` should be added to
71
- the project to enable support for Hazelcast. Since there is a default `hazelcast.xml`
72
- configuration file at the root of the classpath, it is used to automatically configure
73
- the underlying `HazelcastInstance`.
75
+ Both `com.hazelcast:hazelcast` and `com.hazelcast:hazelcast-spring` should be added
76
+ to the project to enable support for Hazelcast. Since there is a default
77
+ `hazelcast.xml` configuration file at the root of the classpath, it is used to
78
+ automatically configure the underlying `HazelcastInstance`.
79
+
80
+ TIP: Run sample cache application using Hazelcast with
81
+ `$mvn spring-boot:run -Phazelcast`.
74
82
75
83
76
84
77
85
=== Infinispan
78
86
Add the `org.infinispan:infinispan-spring4-embedded` dependency to enable support for
79
- Infinispan. There is no default location that Infinispan uses to look for a config file
80
- so if you don't specify anything it will bootstrap on a hardcoded default. You can set
81
- the `spring.cache.infinispan.config` property to use the provided `infinispan.xml`
82
- configuration instead.
87
+ Infinispan. There is no default location that Infinispan uses to look for a config
88
+ file so if you don't specify anything it will bootstrap on a hardcoded default. You
89
+ can set the `spring.cache.infinispan.config` property to use the provided
90
+ `infinispan.xml` configuration instead.
91
+
92
+ TIP: Run sample cache application using Hazelcast with
93
+ `$mvn spring-boot:run -Pinfinispan`.
83
94
84
95
85
96
86
97
=== Couchbase
87
- Add the `java-client` and `couchbase-spring-cache` dependencies and make sure that you
88
- have setup at least a `spring.couchbase.bootstrap-hosts` property.
98
+ Add the `java-client` and `couchbase-spring-cache` dependencies and make sure that
99
+ you have setup at least a `spring.couchbase.bootstrap-hosts` property.
100
+
101
+ TIP: Run sample cache application using Hazelcast with
102
+ `$mvn spring-boot:run -Pcouchbase`.
89
103
90
104
91
105
92
106
=== Redis
93
- Add the `spring-boot-starter-data-redis` and make sure it is configured properly (by default,
94
- a redis instance with the default settings is expected on your local box).
107
+ Add the `spring-boot-starter-data-redis` and make sure it is configured properly (by
108
+ default, a redis instance with the default settings is expected on your local box).
109
+
110
+ TIP: Run sample cache application using Hazelcast with
111
+ `$mvn spring-boot:run -Predis`.
95
112
96
113
97
114
@@ -100,10 +117,16 @@ Simply add the `com.github.ben-manes.caffeine:caffeine` dependency to enable sup
100
117
for Caffeine. You can customize how caches are created in different ways, see
101
118
`application.properties` for an example and the documentation for more details.
102
119
120
+ TIP: Run sample cache application using Hazelcast with
121
+ `$mvn spring-boot:run -Pcaffeine`.
122
+
103
123
104
124
105
125
=== Guava
106
- Spring Boot does not provide any dependency management for _Guava_ so you'll have to add
107
- the `com.google.guava:guava` dependency with a version. You can customize how caches are
108
- created in different ways, see `application.properties` for an example and the
109
- documentation for more details.
126
+ Spring Boot does not provide any dependency management for _Guava_ so you'll have to
127
+ add the `com.google.guava:guava` dependency with a version. You can customize how
128
+ caches are created in different ways, see `application.properties` for an example and
129
+ the documentation for more details.
130
+
131
+ TIP: Run sample cache application using Hazelcast with
132
+ `$mvn spring-boot:run -Pguava`.
0 commit comments