Polish contribution

Closes gh-8202
This commit is contained in:
Stephane Nicoll 2017-02-06 10:34:22 +01:00
parent 31ed70e1b8
commit 4d7b03b002
2 changed files with 70 additions and 64 deletions

View File

@ -15,8 +15,8 @@ abstraction is supported by many caching libraries, including:
* Generic provider based on `org.springframework.Cache` bean definition(s)
The sample defines a simple `CountryService` that caches countries by ISO code. When
the application starts a client invokes the service with a random code every 500ms. You
can look at the `/metrics` endpoint to review the cache statistics if your chosen
the application starts a client invokes the service with a random code every 500ms.
You can look at the `/metrics` endpoint to review the cache statistics if your chosen
caching provider is supported.
@ -26,30 +26,31 @@ The sample uses Spring's cache annotation. If you want to use the JSR-107 annota
instead, simply add the `javax.cache:cache-api` dependency to the project. No further
configuration is necessary.
NOTE: You can use the JSR-107 annotations with _any_ cache provider; a JSR-107 compliant
cache provider is not necessary.
NOTE: You can use the JSR-107 annotations with _any_ cache provider; a JSR-107
compliant cache provider is not necessary.
== Using a different cache provider
Initially, the project does not define any caching library so the abstraction works
on simple `ConcurrentHashMap`-based caches. You can try out your favorite caching library
as explained below.
on simple `ConcurrentHashMap`-based caches. You can try out your favorite caching
library as explained below.
=== JCache (JSR-107)
If you want to configure your cache infrastructure via the standard, you need a compliant
implementation and the JSR-107 api. You first need to add `javax.cache:cache-api` to your
project. Then you could try the following:
If you want to configure your cache infrastructure via the standard, you need a
compliant implementation and the JSR-107 api. You first need to add
`javax.cache:cache-api` to your project. Then you could try the following:
* `EhCache 3`: add `org.ehcache:ehcache`
* `Hazelcast`: add `com.hazelcast:hazelcast`
* `Infinispan`: add `org.infinispan:infinispan-jcache`
TIP: Certain cache providers do not create a default cache on-the-fly if it does not exist
so you might need to update the sample to create the caches on startup or specify the
location to the provider-specific file via the `spring.cache.jcache.config` property.
TIP: Certain cache providers do not create a default cache on-the-fly if it does not
exist so you might need to update the sample to create the caches on startup or
specify the location to the provider-specific file via the
`spring.cache.jcache.config` property.
NOTE: Any other JSR-107 compliant provider is also supported but Spring Boot may not
offer a dependency management entry for it. You will have to add it with the version
@ -59,45 +60,56 @@ of the library that you want to use.
=== EhCache 2.x
Simply add the `net.sf.ehcache:ehcache` dependency to the project. Since there is a
default `ehcache.xml` configuration file at the root of the classpath, it is automatically
used to configure the underlying `CacheManager`. Note that EhCache 3 uses a different
format and doesn't default to `ehcache.xml` anymore. Check
http://www.ehcache.org/documentation/3.0/xml.html[the documentation] for more details.
default `ehcache.xml` configuration file at the root of the classpath,
it is automatically used to configure the underlying `CacheManager`.
Note that EhCache 3 uses a different format and doesn't default to `ehcache.xml`
anymore. Check http://www.ehcache.org/documentation/3.0/xml.html[the documentation]
for more details.
TIP: Run sample cache application using EhCache with
`$mvn spring-boot:run -Pehcache2`.
Run sample cache application using EhCache with `$mvn -P ehcache spring-boot:run`
=== Hazelcast
Both `com.hazelcast:hazelcast` and `com.hazelcast:hazelcast-spring` should be added to
the project to enable support for Hazelcast. Since there is a default `hazelcast.xml`
configuration file at the root of the classpath, it is used to automatically configure
the underlying `HazelcastInstance`.
Both `com.hazelcast:hazelcast` and `com.hazelcast:hazelcast-spring` should be added
to the project to enable support for Hazelcast. Since there is a default
`hazelcast.xml` configuration file at the root of the classpath, it is used to
automatically configure the underlying `HazelcastInstance`.
TIP: Run sample cache application using Hazelcast with
`$mvn spring-boot:run -Phazelcast`.
Run sample cache application using Hazelcast with `$mvn -P hazelcast spring-boot:run`
=== Infinispan
Add the `org.infinispan:infinispan-spring4-embedded` dependency to enable support for
Infinispan. There is no default location that Infinispan uses to look for a config file
so if you don't specify anything it will bootstrap on a hardcoded default. You can set
the `spring.cache.infinispan.config` property to use the provided `infinispan.xml`
configuration instead.
Infinispan. There is no default location that Infinispan uses to look for a config
file so if you don't specify anything it will bootstrap on a hardcoded default. You
can set the `spring.cache.infinispan.config` property to use the provided
`infinispan.xml` configuration instead.
TIP: Run sample cache application using Hazelcast with
`$mvn spring-boot:run -Pinfinispan`.
Run sample cache application using Infinispan with `$mvn -P infinispan spring-boot:run`
=== Couchbase
Add the `java-client` and `couchbase-spring-cache` dependencies and make sure that you
have setup at least a `spring.couchbase.bootstrap-hosts` property.
Add the `java-client` and `couchbase-spring-cache` dependencies and make sure that
you have setup at least a `spring.couchbase.bootstrap-hosts` property.
TIP: Run sample cache application using Hazelcast with
`$mvn spring-boot:run -Pcouchbase`.
Start a Couchbase server, then run the sample cache application using Couchbase with `$mvn -P couchbase spring-boot:run`
=== Redis
Add the `spring-boot-starter-data-redis` and make sure it is configured properly (by default,
a redis instance with the default settings is expected on your local box).
Add the `spring-boot-starter-data-redis` and make sure it is configured properly (by
default, a redis instance with the default settings is expected on your local box).
TIP: Run sample cache application using Hazelcast with
`$mvn spring-boot:run -Predis`.
Start a Redis server, then run the sample cache application using Redis with `$mvn -P redis spring-boot:run`
=== Caffeine
@ -105,13 +117,16 @@ Simply add the `com.github.ben-manes.caffeine:caffeine` dependency to enable sup
for Caffeine. You can customize how caches are created in different ways, see
`application.properties` for an example and the documentation for more details.
Run sample cache application using Caffeine with `$mvn -P caffeine spring-boot:run`
TIP: Run sample cache application using Hazelcast with
`$mvn spring-boot:run -Pcaffeine`.
=== Guava
Spring Boot does not provide any dependency management for _Guava_ so you'll have to add
the `com.google.guava:guava` dependency with a version. You can customize how caches are
created in different ways, see `application.properties` for an example and the
documentation for more details.
Spring Boot does not provide any dependency management for _Guava_ so you'll have to
add the `com.google.guava:guava` dependency with a version. You can customize how
caches are created in different ways, see `application.properties` for an example and
the documentation for more details.
Run sample cache application using Guava with `$mvn -P guava spring-boot:run`
TIP: Run sample cache application using Hazelcast with
`$mvn spring-boot:run -Pguava`.

View File

@ -49,8 +49,6 @@
</plugins>
</build>
<profiles>
<!-- JCache API (JSR-107 support) -->
<!-- Include with any of the caching providers below using, e.g. `$mvn -P jcache,hazelcast spring-boot:run` -->
<profile>
<id>jcache</id>
<dependencies>
@ -60,7 +58,6 @@
</dependency>
</dependencies>
</profile>
<!-- mvn -P caffeine spring-boot:run -->
<profile>
<id>caffeine</id>
<dependencies>
@ -70,8 +67,6 @@
</dependency>
</dependencies>
</profile>
<!-- Start Couchbase server, then... -->
<!-- mvn -P couchbase spring-boot:run -->
<profile>
<id>couchbase</id>
<dependencies>
@ -85,9 +80,8 @@
</dependency>
</dependencies>
</profile>
<!-- mvn -P ehcache spring-boot:run -->
<profile>
<id>ehcache</id>
<id>ehcache2</id>
<dependencies>
<dependency>
<groupId>net.sf.ehcache</groupId>
@ -95,29 +89,19 @@
</dependency>
</dependencies>
</profile>
<!-- Start a Ehcache server, then... -->
<!-- mvn -P org-ehcache spring-boot:run -->
<profile>
<id>org-ehcache</id>
<id>ehcache</id>
<dependencies>
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
</dependency>
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
</dependencies>
</profile>
<!-- mvn -P guava spring-boot:run -->
<profile>
<id>guava</id>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
</dependencies>
</profile>
<!-- mvn -P hazelcast spring-boot:run -->
<profile>
<id>hazelcast</id>
<dependencies>
@ -131,7 +115,6 @@
</dependency>
</dependencies>
</profile>
<!-- mvn -P infinispan spring-boot:run -->
<profile>
<id>infinispan</id>
<dependencies>
@ -145,8 +128,6 @@
</dependency>
</dependencies>
</profile>
<!-- Start a Redis Server ($. <redis-install>/src/redis-server), then... -->
<!-- mvn -P redis spring-boot:run -->
<profile>
<id>redis</id>
<dependencies>
@ -156,5 +137,15 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>guava</id>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>