You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add dedicated section on executing lua scripts via the reactive infrastructure, rephrase some other parts adapt non-Javadoc comments to code style.
Original Pull Request: #280
Copy file name to clipboardExpand all lines: src/main/asciidoc/reference/reactive-redis.adoc
+34-15Lines changed: 34 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ This section covers reactive Redis support and how to get started. You will find
7
7
[[redis:reactive:requirements]]
8
8
== Redis Requirements
9
9
10
-
Spring Redis requires Redis 2.6 or above and Java SE 8.0 or above. In terms of language bindings (or connectors), Spring Data Redis integrates with http://github.com/lettuce-io/lettuce-core[Lettuce] as the only reactive Java connector. Spring Data Redis uses https://projectreactor.io/[Project Reactor] as reactive composition library.
10
+
Spring Data Redis requires Redis 2.6 or above and Java SE 8.0 or above. In terms of language bindings (or connectors), Spring Data Redis currently integrates with http://github.com/lettuce-io/lettuce-core[Lettuce] as the only reactive Java connector. https://projectreactor.io/[Project Reactor] is used as reactive composition library.
11
11
12
12
[[redis:reactive:connectors]]
13
13
== Connecting to Redis using a reactive driver
@@ -17,13 +17,13 @@ One of the first tasks when using Redis and Spring is to connect to the store th
17
17
[[redis:reactive:connectors:operation-modes]]
18
18
=== Redis Operation Modes
19
19
20
-
Redis can be run as Standalone server, with <<redis:sentinel,Redis Sentinel>> or in <<cluster,Redis Cluster>> mode.
20
+
Redis can be run as standalone server, with <<redis:sentinel,Redis Sentinel>> or in <<cluster,Redis Cluster>> mode.
21
21
http://github.com/lettuce-io/lettuce-core[Lettuce] supports all above mentioned connection types.
22
22
23
23
[[redis:reactive:connectors:connection]]
24
24
=== ReactiveRedisConnection and ReactiveRedisConnectionFactory
25
25
26
-
`ReactiveRedisConnection` provides the building block for Redis communication as it handles the communication with the Redis back-end. It also automatically translates the underlying connecting library exceptions to Spring's consistent DAO exception http://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/data-access.html#dao-exceptions[hierarchy] so one can switch the connectors without any code changes as the operation semantics remain the same.
26
+
`ReactiveRedisConnection` provides the building block for Redis communication as it handles the communication with the Redis back-end. It also automatically translates the underlying driver exceptions to Spring's consistent DAO exception http://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/data-access.html#dao-exceptions[hierarchy] so one can switch the connectors without any code changes as the operation semantics remain the same.
27
27
28
28
Active ``ReactiveRedisConnection``s are created through `ReactiveRedisConnectionFactory`. In addition, the factories act as ``PersistenceExceptionTranslator``s, meaning once declared, they allow one to do transparent exception translation. For example, exception translation through the use of the `@Repository` annotation and AOP. For more information see the dedicated http://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/data-access.html#orm-exception-translation[section] in Spring Framework documentation.
29
29
@@ -34,45 +34,43 @@ The easiest way to work with a `ReactiveRedisConnectionFactory` is to configure
34
34
[[redis:reactive:connectors:lettuce]]
35
35
=== Configuring Lettuce connector
36
36
37
-
https://github.com/lettuce-io/lettuce-core[Lettuce] is a http://netty.io/[netty]-based open-source connector supported by Spring Data Redis through the `org.springframework.data.redis.connection.lettuce` package.
37
+
https://github.com/lettuce-io/lettuce-core[Lettuce] is supported by Spring Data Redis through the `org.springframework.data.redis.connection.lettuce` package.
38
38
39
-
Its configuration is probably easy to guess:
39
+
Setting up `ReactiveRedisConnectionFactory` for Lettuce can be done as follows:
40
40
41
41
[source,java]
42
42
----
43
43
@Bean
44
-
public ReactiveRedisConnectionFactory lettuceConnectionFactory() {
44
+
public ReactiveRedisConnectionFactory connectionFactory() {
45
45
return new LettuceConnectionFactory("localhost", 6379);
46
46
}
47
47
----
48
48
49
-
A more sophisticated configuration could look like:
49
+
A more sophisticated configuration, including SSL and timeouts, using `LettuceClientConfigurationBuilder` might look like below:
50
50
51
51
[source,java]
52
52
----
53
53
@Bean
54
54
public ReactiveRedisConnectionFactory lettuceConnectionFactory() {
55
55
56
-
RedisStandaloneConfiguration standalone = new RedisStandaloneConfiguration("localhost", 6379);
return new LettuceConnectionFactory(standalone, clientConfig);
62
+
return new LettuceConnectionFactory(new RedisStandaloneConfiguration("localhost", 6379), clientConfig);
65
63
}
66
64
----
67
65
68
-
There are also a few Lettuce-specific connection parameters that can be tweaked. See `LettuceClientConfiguration` for more details.
66
+
For more detailed client configuration tweaks have a look at `LettuceClientConfiguration`.
69
67
70
68
[[redis:reactive:template]]
71
69
== Working with Objects through ReactiveRedisTemplate
72
70
73
71
Most users are likely to use `ReactiveRedisTemplate` and its corresponding package `org.springframework.data.redis.core` - the template is in fact the central class of the Redis module due to its rich feature set. The template offers a high-level abstraction for Redis interactions. While `ReactiveRedisConnection` offers low level methods that accept and return binary values (`ByteBuffer`), the template takes care of serialization and connection management, freeing the user from dealing with such details.
74
72
75
-
Moreover, the template provides operations views (following the grouping from Redis command http://redis.io/commands[reference]) that offer rich, generified interfaces for working against a certain type as described below:
73
+
Moreover, the template provides operation views (following the grouping from Redis command http://redis.io/commands[reference]) that offer rich, generified interfaces for working against a certain type as described below:
76
74
77
75
.Operational views
78
76
[width="80%",cols="<1,<2",options="header"]
@@ -106,7 +104,7 @@ Moreover, the template provides operations views (following the grouping from Re
106
104
107
105
Once configured, the template is thread-safe and can be reused across multiple instances.
108
106
109
-
Out of the box, `ReactiveRedisTemplate` uses a Java-based serializer for most of its operations. This means that any object written or read by the template will be serialized/deserialized through Java throug `RedisElementWriter` respective `RedisElementReader`. The serialization context is passed to the template upon construction, and the Redis module offers several implementations available in the `org.springframework.data.redis.serializer` package - see <<redis:serializer>> for more information.
107
+
Out of the box, `ReactiveRedisTemplate` uses a Java-based serializer for most of its operations. This means that any object written or read by the template will be serialized/deserialized through `RedisElementWriter` respective `RedisElementReader`. The serialization context is passed to the template upon construction, and the Redis module offers several implementations available in the `org.springframework.data.redis.serializer` package - see <<redis:serializer>> for more information.
0 commit comments