4

Need to run a batch of commands in redis-cluster mode with lettuce.For commands that should run in one partition, i hope to run them in one node sequentially.

As i know, lettuce can support redis pipelining by set the AutoFlushCommands state to be false. But in redis-cluster mode, the command may be send to different nodes in one partition. Is there any way to avoid the problem?

Bing
  • 41
  • 1
  • 3

1 Answers1

3

It does, at least, according to Lettuce:https://github.com/lettuce-io/lettuce-core/wiki/Pipelining-and-command-flushing

Command flushing is an advanced topic and in most cases (i.e. unless your use-case is a single-threaded mass import application) you won’t need it as Lettuce uses pipelining by default.

It means, it uses pipelining by default, I don't think this is true or clear, as it also mentions:

A flush is an expensive system call and impacts performance. Batching, disabling auto-flushing

The AutoFlushCommands state is set per connection and therefore affects all threads using the shared connection. If you want to omit this effect, use dedicated connections. The AutoFlushCommands state cannot be set on pooled connections by the lettuce connection pooling.

Which means, if you want true Redis pipelining http://redis.io/topics/pipelining, you can do that as well with some extra effort.

kisna
  • 2,869
  • 1
  • 25
  • 30
  • 1
    April 2023 - Lettuce's own documentation is out of date - https://lettuce.io/core/release/api/io/lettuce/core/api/async/BaseRedisAsyncCommands.html#setAutoFlushCommands-boolean- disable autoflush on the connection and not the Commands object. – David Apr 06 '23 at 22:18