Polish "Add Redis application properties example"

See gh-33965
This commit is contained in:
Andy Wilkinson
2023-02-01 15:42:59 +00:00
parent b6f900dd98
commit 2bf780237a

View File

@@ -34,11 +34,24 @@ TIP: We also provide a `spring-boot-starter-data-redis-reactive` "`Starter`" for
[[data.nosql.redis.connecting]]
==== Connecting to Redis
You can inject an auto-configured `RedisConnectionFactory`, `StringRedisTemplate`, or vanilla `RedisTemplate` instance as you would any other Spring Bean.
By default, the instance tries to connect to a Redis server at `localhost:6379`.
The following listing shows an example of such a bean:
include::code:MyBean[]
By default, the instance tries to connect to a Redis server at `localhost:6379`.
You can specify custom connection details using `spring.redis.*` properties, as shown in the following example:
[source,yaml,indent=0,subs="verbatim",configprops,configblocks]
----
spring:
redis:
host: "localhost"
port: 6379
database: 0
username: "user"
password: "secret"
----
TIP: You can also register an arbitrary number of beans that implement `LettuceClientConfigurationBuilderCustomizer` for more advanced customizations.
`ClientResources` can also be customized using `ClientResourcesBuilderCustomizer`.
If you use Jedis, `JedisClientConfigurationBuilderCustomizer` is also available.
@@ -48,20 +61,7 @@ If you add your own `@Bean` of any of the auto-configured types, it replaces the
By default, a pooled connection factory is auto-configured if `commons-pool2` is on the classpath.
Alternatively, you can specify connection details using discrete properties.
For example, you might declare the following settings in your `application.properties`:
[source,yaml,indent=0,subs="verbatim",configprops,configblocks]
----
spring:
data:
redis:
host: "localhost"
port: 6379
database: 0
username: "user"
password: "secret"
----
[[data.nosql.mongodb]]
=== MongoDB