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

Go: Implementing DEL command #2294

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MikeMwita
Copy link
Collaborator

  • Implemented DEL command

@MikeMwita MikeMwita requested a review from a team as a code owner September 15, 2024 12:37
@MikeMwita MikeMwita added the go golang wrapper label Sep 15, 2024
@MikeMwita MikeMwita self-assigned this Sep 15, 2024
@MikeMwita MikeMwita linked an issue Sep 15, 2024 that may be closed by this pull request
2 tasks
suite.runWithDefaultClients(func(client api.BaseClient) {
key1 := "testKey1"
key2 := "testKey2"
key3 := "testKey3"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider using keys specific to tests or uuid generator for unique keys as these keys might clash with other tests and lead to unpredictable results.

Copy link
Contributor

@eifrah-aws eifrah-aws Sep 16, 2024

Choose a reason for hiding this comment

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

Nice catch!

// result, err := client.Del("key1", "key2", "key3")
//
// [valkey.io]: https://valkey.io/commands/del/
Del(keys ...string) (int64, error)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's try to maintain the uniformity in the function signature. Either we can use keys []string here or pass keys ... string at other places.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't use varargs in other clients, please, use []

// Returns the number of keys that were removed.
//
// For example:
// result, err := client.Del("key1", "key2", "key3")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add how the result will look like. (You can refer the templates of other commands)

func (client *baseClient) Del(keys ...string) (int64, error) {
if client.coreClient == nil {
return 0, &ClosingError{"Del command failed. The client is closed."}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a redundant check and can be removed from here as it's already being checked in ExecuteCommand function.

// result, err := client.Del("key1", "key2", "key3")
//
// [valkey.io]: https://valkey.io/commands/del/
Del(keys ...string) (int64, error)
Copy link
Collaborator

Choose a reason for hiding this comment

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

On referring to other clients like Java, Del command is not part of StringCommands interface and it's a part of GenericBaseCommands. Can we please add another interface and define it there?

suite.runWithDefaultClients(func(client api.BaseClient) {
key1 := "testKey1"
key2 := "testKey2"
key3 := "testKey3"
Copy link
Contributor

@eifrah-aws eifrah-aws Sep 16, 2024

Choose a reason for hiding this comment

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

Nice catch!

@@ -371,4 +371,18 @@ type StringCommands interface {
//
//[valkey.io]: https://valkey.io/commands/getdel/
GetDel(key string) (string, error)

// Del removes the specified keys. A key is ignored if it does not exist.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please copy docs from other clients to ensure that they are all aligned.
Add a cluster notice:

* @apiNote When in cluster mode, the command may route to multiple nodes when <code>keys</code>
* map to different hash slots.

// result, err := client.Del("key1", "key2", "key3")
//
// [valkey.io]: https://valkey.io/commands/del/
Del(keys ...string) (int64, error)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't use varargs in other clients, please, use []

@MikeMwita MikeMwita force-pushed the implement-del-command branch 3 times, most recently from db090e0 to dfa827b Compare September 23, 2024 19:56
@eifrah-aws
Copy link
Contributor

Can you please re-base this PR branch and re-submit?

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

Successfully merging this pull request may close these issues.

GO: implement DEL command
4 participants