Reactive Redis connector

The Spring Data Reactive Redis module may be enabled by importing the spring-boot-starter-data-redis-reactive starter. In contrast to other reactive connectors, the Redis connector does not provide a reactive repository. Consequently, the ReactiveRedisTemplate class becomes the central abstraction for reactive Redis data access. ReactiveRedisTemplate implements the API defined by the ReactiveRedisOperations interface and provides all necessary serialization-deserialization routines. At the same time, ReactiveRedisConnection allows working with raw byte buffers when communicating with Redis.

Along with the ordinary operations for storing and retrieving objects and managing Redis data structures, the template allows subscription to Pub-Sub channels. For example, the convertAndSend(String destination, V message) method publishes the given message to the given channel and returns the number of clients that received the message. The listenToChannel(String... channels) method returns a Flux with messages from the channels of interest. This way, the reactive Redis connector enables not only reactive data storage but also provides a messaging mechanism. Chapter 8Scaling Up with Cloud Streams, describes more how messaging improves the scalability and elasticity of a reactive application.

Spring Data Redis currently integrates with the Lettuce driver (https://github.com/lettuce-io/lettuce-core). It is the only reactive Java connector for Redis. Lettuce version 4.x used RxJava for underlying implementation. However, the 5.x branch of the library switched to Project Reactor.

All reactive connectors except for Couchbase have reactive health indicators. Consequently, database health checks also should not waste any server resources. More on that is covered in Chapter 10And, Finally, Release It!

We are sure that, with time, Spring Data will add more reactive connectors to its ecosystem.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.231.194