now I'm using Spring Webflux with Redis. Since i use Webflux, i chose ReactiveRedisTemplate to use on non-blocking system properly.
After using ReactiveRedisTemplate, i just think of how i can improve redis performance in my project. And i find out using pipeline is the one way.
But ReactiveRedisTemplate only provide execute() method to use pipeline and it ignore the result of redis action. I don't know i perfectly undestand, i think it's only for CUD, not READ.
So, there are several questions.
- Why doesn't ReactiveRedisTemplate provide pipeline for READ?
- Webflux choose parallel threading model to improve the performance. so I think Redis pipeline sometimes is not the best way. Because the big reason to use pipeline is to decrease RTT. so Why does ReactiveRedisTemplate provide pipeline for CUD(as i understand, execute())?
I tried execute() method
public Mono<Long> unlinkInPipeline(Flux<String> values) {
return reactiveRedisTemplate.execute(connection ->
values.flatMap(id -> {
return Flux.just(ByteBuffer.wrap(getKey(id).getBytes()));
})
.flatMap(buffer -> connection.keyCommands().unlink(buffer)), false)
.reduce(Long::sum)
.defaultIfEmpty(0L);
}