Reputation: 31
Lettuce github: https://github.com/lettuce-io/lettuce-core/issues/1085
1 “Spring Data Redis uses Lettuce’s synchronous and reactive API.” it says Does that mean it works basically synchronously?
I referred to the official Spring Data Redis Lettuce document.
2 Is the presence or absence of Reactive API support the same as the presence or absence of asynchronous API support?
3 It was written in the table as follows: "Reactive (non-blocking) API X" However, upon reading the document more closely, "11. There is an article like Reactive Redis support". What is right?
docs: https://docs.spring.io/spring-data/data-redis/docs/current/reference/html/#redis:reactive
Upvotes: 0
Views: 494
Reputation: 7981
It depends on what part of the Spring Data Redis library and APIs you are using. One of the common ways to use Spring Data Redis, and Spring in general, is through the use of a Template, such as the (Reactive)RedisTemplate.
Therefore, unless you are explicitly using the Reactive APIs in Spring Data Redis (e.g. ReactiveRedisTemplate
(Javadoc)), working with Monos
and Fluxes
, and rather, you are using the imperative APIs (e.g. RedisTemplate
(Javadoc)) instead, then the operations are "synchronous" and blocking.
Under-the-hood, even though Lettuce supports asynchronous operations and is used that way by default in Spring Data Redis, SD Redis will wait (up to a given command timeout if configured) on the (Lettuce Redis)Future
to complete before returning.
For the curious reader, you can observe this is actually the case in Spring Data Redis, from here to here and here. Notice the
await(..)
.
The Reactive API is asynchronous, non-blocking and wraps any command invocation in a Reactive type before executing the command, returning immediately.
TIP: For example, see here in the Reactive handling, where the action is the Redis command invocation.
Upvotes: 0