@@ -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,59 +60,73 @@ 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
- Run sample cache application using EhCache with `$mvn -P ehcache spring-boot:run`
68
72
69
73
70
74
=== Hazelcast
71
- Both `com.hazelcast:hazelcast` and `com.hazelcast:hazelcast-spring` should be added to
72
- the project to enable support for Hazelcast. Since there is a default `hazelcast.xml`
73
- configuration file at the root of the classpath, it is used to automatically configure
74
- 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`.
75
82
76
- Run sample cache application using Hazelcast with `$mvn -P hazelcast spring-boot:run`
77
83
78
84
79
85
=== Infinispan
80
86
Add the `org.infinispan:infinispan-spring4-embedded` dependency to enable support for
81
- Infinispan. There is no default location that Infinispan uses to look for a config file
82
- so if you don't specify anything it will bootstrap on a hardcoded default. You can set
83
- the `spring.cache.infinispan.config` property to use the provided `infinispan.xml`
84
- 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`.
85
94
86
- Run sample cache application using Infinispan with `$mvn -P infinispan spring-boot:run`
87
95
88
96
89
97
=== Couchbase
90
- Add the `java-client` and `couchbase-spring-cache` dependencies and make sure that you
91
- 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`.
92
103
93
- Start a Couchbase server, then run the sample cache application using Couchbase with `$mvn -P couchbase spring-boot:run`
94
104
95
105
96
106
=== Redis
97
- Add the `spring-boot-starter-data-redis` and make sure it is configured properly (by default,
98
- 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`.
99
112
100
- Start a Redis server, then run the sample cache application using Redis with `$mvn -P redis spring-boot:run`
101
113
102
114
103
115
=== Caffeine
104
116
Simply add the `com.github.ben-manes.caffeine:caffeine` dependency to enable support
105
117
for Caffeine. You can customize how caches are created in different ways, see
106
118
`application.properties` for an example and the documentation for more details.
107
119
108
- Run sample cache application using Caffeine with `$mvn -P caffeine spring-boot:run`
120
+ TIP: Run sample cache application using Hazelcast with
121
+ `$mvn spring-boot:run -Pcaffeine`.
122
+
109
123
110
124
111
125
=== Guava
112
- Spring Boot does not provide any dependency management for _Guava_ so you'll have to add
113
- the `com.google.guava:guava` dependency with a version. You can customize how caches are
114
- created in different ways, see `application.properties` for an example and the
115
- 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.
116
130
117
- Run sample cache application using Guava with `$mvn -P guava spring-boot:run`
131
+ TIP: Run sample cache application using Hazelcast with
132
+ `$mvn spring-boot:run -Pguava`.
0 commit comments