Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support UnifiedJedis transactions without calling multi first #3663

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/redis/clients/jedis/JedisCluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public ClusterPipeline pipelined() {
* @throws UnsupportedOperationException
*/
@Override
public Transaction multi() {
public Transaction transaction(boolean multi) {
throw new UnsupportedOperationException();
}
}
2 changes: 1 addition & 1 deletion src/main/java/redis/clients/jedis/JedisSharding.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public ShardedPipeline pipelined() {
* @throws UnsupportedOperationException
*/
@Override
public Transaction multi() {
public Transaction transaction(boolean multi) {
throw new UnsupportedOperationException();
}
}
14 changes: 11 additions & 3 deletions src/main/java/redis/clients/jedis/UnifiedJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -4844,12 +4844,20 @@ public PipelineBase pipelined() {
}

public AbstractTransaction multi() {
return transaction(true);
}

public AbstractTransaction transaction() {
return transaction(false);
}

public AbstractTransaction transaction(boolean doMulti) {
if (provider == null) {
throw new IllegalStateException("It is not allowed to create Pipeline from this " + getClass());
throw new IllegalStateException("It is not allowed to create Transaction from this " + getClass());
} else if (provider instanceof MultiClusterPooledConnectionProvider) {
return new MultiClusterTransaction((MultiClusterPooledConnectionProvider) provider);
return new MultiClusterTransaction((MultiClusterPooledConnectionProvider) provider, doMulti);
} else {
return new Transaction(provider.getConnection(), true, true);
return new Transaction(provider.getConnection(), doMulti, true);
}
}

Expand Down
Loading