Closed jacekgajek closed 2 months ago
Asynchronous invocations retain the order in which commands are invoked. Synchronous is wrong in that context, because a write internally enqueues Runnable
that performs the actual I/O write using a netty I/O thread.
after the command is written to the netty pipeline
This implies already that we retain the command order so the snippets you provided where get
and delete
order is mixed up lead to different behavior.
Maybe it could specify what happens after the "Future".
Not sure what you refer to. https://github.com/lettuce-io/lettuce-core/wiki/Command-execution-reliability covers a bit of behind-the-scenes. Lettuce's manual isn't a general introduction to asynchronous programming, instead it covers the Lettuce specifics.
Now it makes a perfect sense and I understand everything :) I'm not a newbie, I've been using async libraries quite a lot.
However, I'm new to Lettuce, so you can find my first-sight impression valuable – it's a rare occasion as the most of posts here are written by people who already have been using Lettuce for some time and are familiar with the basics.
Greetings, Jacek
Documentation is going to be overhauled as part of Redis taking over maintenance of the driver and this issue will be considered then, thanks for the report!
Maybe I'm not smart enough, but I think this part of docs https://github.com/lettuce-io/lettuce-core/wiki/Pipelining-and-command-flushing could be improved
Maybe it could specify what happens after the "Future". Since it mentions only pipeline, I thought that just calling methods does nothing synchronously, and I need to call
thenAccept
if I wanted a command be executed after the previous one (which usually is the case with async programming). Sure, examples show that this is how it should be done:Baeldung doesn't have a separate example for async, instead it points to Future documentation which again made me think I need to use
thenAccept
https://www.baeldung.com/java-redis-lettuce
But coming from kotlin coroutines which also has
await
, it's a totally unexpected behaviour. Maybe mention it in javadocs of io.lettuce.core.api.async.RedisAsyncCommands<K, V> async() as well?Another example:
@mp911de https://github.com/lettuce-io/lettuce-core/issues/1627
If this works, then something must be executed synchronously, otherwise it would be equivalent to
Proposal:
Cheers, Jacek