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

Improve code style and do some minor fix in scripting #1312

Merged
merged 5 commits into from
Mar 10, 2023

Conversation

PragmaTwice
Copy link
Member

Related to almost all functions in scripting.

@PragmaTwice PragmaTwice requested review from git-hulk and torwig March 10, 2023 09:20
torwig
torwig previously approved these changes Mar 10, 2023
Comment on lines -112 to +116
if (read_only) {
/* redis.read_only */
lua_pushstring(lua, "read_only");
lua_pushboolean(lua, 1);
lua_settable(lua, -3);
}
/* redis.read_only */
lua_pushstring(lua, "read_only");
lua_pushboolean(lua, read_only);
lua_settable(lua, -3);
Copy link
Member Author

Choose a reason for hiding this comment

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

It is not intuitionistic if the boolean value only exists when read_only is true

Comment on lines -183 to -185
if (level < GetServer()->GetConfig()->log_level) {
return 0;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This level cannot be compared with loglevel in config.

auto redisCmd = cmd_iter->second;
if (read_only && redisCmd->is_write()) {
if (read_only && ~(redisCmd->flags & Redis::kCmdReadOnly)) {
Copy link
Member Author

@PragmaTwice PragmaTwice Mar 10, 2023

Choose a reason for hiding this comment

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

There is no assumption that a command is read-only if it has no write flag

std::string sha;
auto s = createFunction(srv, body, &sha, lua);
auto s = createFunction(srv, body, &sha, lua, false);
Copy link
Member Author

Choose a reason for hiding this comment

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

We do not need to store the script body here.

@PragmaTwice PragmaTwice requested a review from torwig March 10, 2023 14:11
git-hulk
git-hulk previously approved these changes Mar 10, 2023
torwig
torwig previously approved these changes Mar 10, 2023
@PragmaTwice PragmaTwice dismissed stale reviews from torwig and git-hulk via ce4bacd March 10, 2023 15:20
@PragmaTwice PragmaTwice merged commit 1ab1ae8 into apache:unstable Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants