-
The Documentation of Redis guarantees that the commands inside of a transaction are issued sequentially see docs. Is this also guaranteed with lettuce? To be more specific, lets say we have the following code-snippet: RedisAsyncCommands<String, String> api = redisConnection.async();
api.multi();
api.set("testKey", "testValue");
api.get("testKey");
api.set("testKey", "someOtherTestValue");
var future = api.exec(); Will it be guaranteed that the get()-call will only be issued upon the Completion of the set()-call before it? Or do you need to compose the RedisFutures to make sure that they will be issued sequentially? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Commands are sent in-order. The important bit is to not share the same |
Beta Was this translation helpful? Give feedback.
-
What would happen if you would share the StatefulRedisConnection among threads? I imagine it could cause the multi-blocks to fail since the multi blocks of different threads could "mix", is that the correct guess here? Is there a way to share a StatefulRedisConnection without the need to give every thread their own connection (as the connection are quite expensive)? |
Beta Was this translation helpful? Give feedback.
Commands are sent in-order. The important bit is to not share the same
redisConnection
across threads to avoid shared mutable state. Other than that, this is the preferred pattern as you're not awaiting completion and benefitting from pipelining.