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

UnifiedJedis is missing support for transactions #2857

Closed
njibhu opened this issue Jan 31, 2022 · 4 comments
Closed

UnifiedJedis is missing support for transactions #2857

njibhu opened this issue Jan 31, 2022 · 4 comments
Labels

Comments

@njibhu
Copy link

njibhu commented Jan 31, 2022

Description

The new UnifiedJedis class added with Jedis 4.0.0 is missing support for the watch and multi commands.
I also couldn't find a way to easily instantiate from the Transaction class directly from a UnifiedJedis instance.

Redis / Jedis Configuration

Jedis version: 4.1.1

Redis version: 6.x

Java version: 17

@sazzad16
Copy link
Collaborator

sazzad16 commented Feb 1, 2022

@njibhu Transaction makes sense on a strict single connection (like Jedis). UnifiedJedis would rarely be used on a single connection. So it's not feasible to add Transaction in UnifiedJedis.

You can use Transaction directly. We've also added watch and multi there.

@njibhu
Copy link
Author

njibhu commented Feb 1, 2022

@sazzad16 Thanks for the explaination !
Since the single connection client Jedis doesn't support json commands but I need these, I don't have a choice but to use the UnifiedJedis class even though I have a single server.

What would actually be the recommended way to use directly Transaction ? Is there a way to get a single connection from a UnifiedJedis to pass to the Transaction constructor ? Or should I have a normal Jedis instance only to create Transactions and keep the UnifiedJedis for my other queries ?

@sazzad16
Copy link
Collaborator

sazzad16 commented Feb 1, 2022

@njibhu You can create a Connection and use that to create Jedis, UnifiedJedis, Transaction, etc.

try (Connection connection = new Connection(...)) {
  Jedis jedis = new Jedis(connection);
  UnifiedJedis ujedis = new UnifiedJedis(connection);
  Transaction transaction = new Transaction(connection);
}

PS: This is not something that I would confidently recommend for production.

@sazzad16
Copy link
Collaborator

Merged #3361

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants