-
Notifications
You must be signed in to change notification settings - Fork 63
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
feat: add rename and renamenx #299
feat: add rename and renamenx #299
Conversation
Signed-off-by: zztaki <[email protected]>
@@ -148,6 +148,18 @@ class Redis { | |||
virtual Status ZsetsTTL(const Slice& key, uint64_t* timestamp); | |||
virtual Status SetsTTL(const Slice& key, uint64_t* timestamp); | |||
|
|||
virtual Status StringsRename(const Slice& key, Redis* new_inst, const Slice& newkey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key
and newkey
may not be on the same shard. So I use new_inst
to represent newkey's shard and pass it as an arg.
} else if (s.IsNotFound()) { | ||
client->SetRes(CmdRes::kNotFound, s.ToString()); | ||
} else if (s.IsCorruption()) { | ||
client->AppendInteger(0); // newkey already exists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if there is a better error code to represent that newkey already exists, thus returning (int) 0
.
May I ask if it is possible to supplement some Go tests to validate the functionality of this command? |
I haven't implemented it yet. Are there any good examples? :) |
There are Go test files under the path pikiwidb/tests, which can be referred to for inspiration. |
https://github.com/redis/go-redis/blob/master/commands_test.go This might be helpful to you. |
Thank you for your help! I will complete it at night. |
Signed-off-by: zztaki <[email protected]>
cicheck |
#30
This PR aims to add rename and renamenx commands for pikiwidb.
Running
./pikiwidbtests.sh basic
There are a few places that I think need to be focused on.