Skip to content

Allow EVAL_RO and EVALSHA_RO to be routed to read replica #2494

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

Merged
merged 5 commits into from
Dec 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions redis/commands/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
[
"BITCOUNT",
"BITPOS",
"EVAL_RO",
"EVALSHA_RO",
"EXISTS",
"GEODIST",
"GEOHASH",
Expand Down
2 changes: 1 addition & 1 deletion redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5139,7 +5139,7 @@ def eval_ro(
"""
The read-only variant of the EVAL command

Execute the read-only Lue ``script`` specifying the ``numkeys`` the script
Execute the read-only Lua ``script`` specifying the ``numkeys`` the script
will touch and the key names and argument values in ``keys_and_args``.
Returns the result of the script.

Expand Down
10 changes: 9 additions & 1 deletion tests/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,15 @@ def parse_response_mock_third(connection, *args, **options):
read_cluster.get("foo")
read_cluster.get("foo")
read_cluster.get("foo")
mocks["send_command"].assert_has_calls([call("READONLY")])
mocks["send_command"].assert_has_calls(
[
call("READONLY"),
call("GET", "foo"),
call("READONLY"),
call("GET", "foo"),
call("GET", "foo"),
]
)

def test_keyslot(self, r):
"""
Expand Down
2 changes: 0 additions & 2 deletions tests/test_scripting.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def test_eval_multiply(self, r):

@skip_if_server_version_lt("7.0.0")
@skip_if_redis_enterprise()
@pytest.mark.onlynoncluster
def test_eval_ro(self, r):
r.set("a", "b")
assert r.eval_ro("return redis.call('GET', KEYS[1])", 1, "a") == b"b"
Expand Down Expand Up @@ -157,7 +156,6 @@ def test_evalsha(self, r):

@skip_if_server_version_lt("7.0.0")
@skip_if_redis_enterprise()
@pytest.mark.onlynoncluster
def test_evalsha_ro(self, r):
r.set("a", "b")
get_sha = r.script_load("return redis.call('GET', KEYS[1])")
Expand Down