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

Java: Add FLUSHDB command. #1593

Merged
merged 5 commits into from
Jun 18, 2024

Conversation

Yury-Fridlyand
Copy link
Collaborator

Issue #, if available:
N/A

Description of changes:
https://redis.io/docs/latest/commands/flushdb/

Almost copy-paste from #1368

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

* Add `FLUSHDB` command.

Signed-off-by: Yury-Fridlyand <[email protected]>

* Address PR comments.

Signed-off-by: Yury-Fridlyand <[email protected]>

---------

Signed-off-by: Yury-Fridlyand <[email protected]>
@Yury-Fridlyand Yury-Fridlyand added the java issues and fixes related to the java client label Jun 17, 2024
@Yury-Fridlyand Yury-Fridlyand requested a review from a team as a code owner June 17, 2024 16:16
Signed-off-by: Yury-Fridlyand <[email protected]>
* assert response.equals("OK");
* }</pre>
*/
CompletableFuture<String> flushdb(SingleNodeRoute route);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only single node here? especially since the default is a multinode route

Copy link
Contributor

@acarbonetto acarbonetto Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • update to multinode or update comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied that from flushall - Route includes ALL_NODES which always fails, because replicas are RO. Even though it may fail now with RANDOM route too.
In a dark future it is nice to have better route distinuishment by their target - RO and non-RO alongside with single/multi node. In that case we can put here non-RO route to protect a user.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the users want to send to all primaries? I guess the thinking is they should use the non-route function since it defaults to all primaries?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think yes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They have to be smart then. Thanks for asking Bar - I guess we can either let the user fail (giving them all options) or limit their options but maybe close some edge cases.

@@ -668,6 +668,8 @@ private static Object[] serverManagementCommands(BaseTransaction<?> transaction)
.lolwut(1)
.flushall()
.flushall(ASYNC)
.flushdb()
.flushdb(ASYNC)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test will fail if we run against 6.1 or prior

Copy link
Collaborator Author

@Yury-Fridlyand Yury-Fridlyand Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting with Redis version 6.2.0: Added the SYNC flushing mode modifier.

No fix needed here, I use ASYNC.
Thanks for catching that!

Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
@Yury-Fridlyand Yury-Fridlyand merged commit 9a29618 into valkey-io:main Jun 18, 2024
46 checks passed
@Yury-Fridlyand Yury-Fridlyand deleted the java/integ_yuryf_FLUSHDB branch June 18, 2024 23:33
cyip10 pushed a commit to Bit-Quill/valkey-glide that referenced this pull request Jun 19, 2024
* Java: Add `FLUSHDB` command. (#366)

Signed-off-by: Yury-Fridlyand <[email protected]>
cyip10 pushed a commit to Bit-Quill/valkey-glide that referenced this pull request Jun 24, 2024
* Java: Add `FLUSHDB` command. (#366)

Signed-off-by: Yury-Fridlyand <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java issues and fixes related to the java client
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants