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

Add support of lua function 'redis.setresp()' #2130

Merged
merged 6 commits into from
Mar 1, 2024

Conversation

git-hulk
Copy link
Member

@git-hulk git-hulk commented Feb 29, 2024

Except for the redis.setresp function, it fixes the different behavior with Redis in Lua script.

Before applying this PR, the Lua script will return the result in RESP3 format
if the connection is connected with HELLO 3 command. But for Redis,
it will always use RESP2 unless users explicitly set it with redis.setresp(3).

// Kvrocks

❯ redis-cli -3 -p 6666

127.0.0.1:6666> EVAL 'return redis.call("hgetall","hash")' 0
1# "f1" => "v1"

// Redis

❯ redis-cli -3 
127.0.0.1:6379> EVAL 'return redis.call("hgetall","hash")' 0
1) "f1"
2) "v1"

After applying this PR, it will behaves consistently with Redis:

❯ redis-cli -3 -p 6666
127.0.0.1:6666> EVAL 'redis.setresp(3);return redis.call("hgetall","hash")' 0
1# "f1" => "v1"
127.0.0.1:6666> EVAL 'return redis.call("hgetall","hash")' 0
1) "f1"
2) "v1"

@git-hulk git-hulk mentioned this pull request Feb 29, 2024
2 tasks
@git-hulk git-hulk changed the title Add support of lua function 'redis.resp()' Add support of lua function 'redis.setresp()' Mar 1, 2024
@git-hulk git-hulk marked this pull request as ready for review March 1, 2024 09:36
enjoy-binbin
enjoy-binbin previously approved these changes Mar 1, 2024
torwig
torwig previously approved these changes Mar 1, 2024
@git-hulk git-hulk dismissed stale reviews from torwig and enjoy-binbin via 7ea8b4c March 1, 2024 10:22
Copy link

sonarcloud bot commented Mar 1, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
8.6% Duplication on New Code (required ≤ 5%)

See analysis details on SonarCloud

@git-hulk
Copy link
Member Author

git-hulk commented Mar 1, 2024

Thanks for your review. @enjoy-binbin @torwig

@git-hulk git-hulk merged commit 4a8fb4b into apache:unstable Mar 1, 2024
29 of 30 checks passed
caipengbo pushed a commit that referenced this pull request Mar 3, 2024
Except for the `redis.setresp` function, it fixes the different behavior with Redis in Lua script.

Before applying this PR, the Lua script will return the result in RESP3 format
if the connection is connected with `HELLO 3` command. But for Redis,
it will always use RESP2 unless users explicitly set it with `redis.setresp(3)`.

```
// Kvrocks

❯ redis-cli -3 -p 6666

127.0.0.1:6666> EVAL 'return redis.call("hgetall","hash")' 0
1# "f1" => "v1"

// Redis

❯ redis-cli -3 
127.0.0.1:6379> EVAL 'return redis.call("hgetall","hash")' 0
1) "f1"
2) "v1"
```

After applying this PR, it will behaves consistently with Redis:

```
❯ redis-cli -3 -p 6666
127.0.0.1:6666> EVAL 'redis.setresp(3);return redis.call("hgetall","hash")' 0
1# "f1" => "v1"
127.0.0.1:6666> EVAL 'return redis.call("hgetall","hash")' 0
1) "f1"
2) "v1"
```


Co-authored-by: Binbin <[email protected]>
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