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

Feat/hash cmd (hset/hget hmset/hmset) #1

Closed
wants to merge 2 commits into from
Closed

Conversation

longfar-ncy
Copy link
Owner

No description provided.

HSetCmd::HSetCmd(const std::string& name, int16_t arity)
: BaseCmd(name, arity, CmdFlagsWrite, AclCategoryWrite | AclCategoryHash) {}

bool HSetCmd::DoInitial(PClient* client) { return true; }
Copy link

Choose a reason for hiding this comment

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

这里要把操作的key 放到client里, client->setkey() 下面那几个命令同样

Copy link
Owner Author

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());
Copy link

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());
Copy link

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, 要把这个排除

Copy link
Owner Author

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; }
Copy link

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是否 对应

@longfar-ncy longfar-ncy deleted the feat/hash-cmd branch November 27, 2023 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants