-
Notifications
You must be signed in to change notification settings - Fork 0
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/hash cmd (hset/hget hmset/hmset) #1
Conversation
HSetCmd::HSetCmd(const std::string& name, int16_t arity) | ||
: BaseCmd(name, arity, CmdFlagsWrite, AclCategoryWrite | AclCategoryHash) {} | ||
|
||
bool HSetCmd::DoInitial(PClient* client) { return true; } |
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 放到client里, client->setkey()
下面那几个命令同样
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.
这个我看cmd_kv有,但是不太理解这一步的作用
} | ||
return; | ||
} | ||
client->AppendContent(reply.ReadStringWithoutCRLF()); |
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.
client里有一个 AppendStringRaw
可以直接设置字符串, 不用ReadStringWithoutCRLF()
去除 \r\n
|
||
void HSetCmd::DoCmd(PClient* client) { | ||
UnboundedBuffer reply; | ||
std::vector<std::string> params(client->argv_.begin(), client->argv_.end()); |
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.
client->argv_.begin()
argv的第一个是 命令名, 这里就是 hset
, 要把这个排除
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.
但是在hash.cc:hset()这个函数里,我看要包含命令本身
HMSetCmd::HMSetCmd(const std::string& name, int16_t arity) | ||
: BaseCmd(name, arity, CmdFlagsWrite, AclCategoryWrite | AclCategoryHash) {} | ||
|
||
bool HMSetCmd::DoInitial(PClient* client) { return true; } |
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放到client里, 这里参数长度是变长的, 应该判断一下 k v 的数量是否是2的倍数, 也是就是 field和value是否 对应
No description provided.