Skip to content

Commit d693221

Browse files
zakafzach-ieedvora-h
authored
Allow EVAL_RO and EVALSHA_RO to be routed to read replica (#2494)
* fix typo (Lue -> Lua) * run eval_ro, evalsha_ro test on redis cluster * Add eval_ro, evalsha_ro to read only commands * assert that commands are run in a round robin manner Co-authored-by: zach.lee <zach.lee@sendbird.com> Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
1 parent 55298e4 commit d693221

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

redis/commands/cluster.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
[
5353
"BITCOUNT",
5454
"BITPOS",
55+
"EVAL_RO",
56+
"EVALSHA_RO",
5557
"EXISTS",
5658
"GEODIST",
5759
"GEOHASH",

redis/commands/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5139,7 +5139,7 @@ def eval_ro(
51395139
"""
51405140
The read-only variant of the EVAL command
51415141
5142-
Execute the read-only Lue ``script`` specifying the ``numkeys`` the script
5142+
Execute the read-only Lua ``script`` specifying the ``numkeys`` the script
51435143
will touch and the key names and argument values in ``keys_and_args``.
51445144
Returns the result of the script.
51455145

tests/test_cluster.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,15 @@ def parse_response_mock_third(connection, *args, **options):
561561
read_cluster.get("foo")
562562
read_cluster.get("foo")
563563
read_cluster.get("foo")
564-
mocks["send_command"].assert_has_calls([call("READONLY")])
564+
mocks["send_command"].assert_has_calls(
565+
[
566+
call("READONLY"),
567+
call("GET", "foo"),
568+
call("READONLY"),
569+
call("GET", "foo"),
570+
call("GET", "foo"),
571+
]
572+
)
565573

566574
def test_keyslot(self, r):
567575
"""

tests/test_scripting.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def test_eval_multiply(self, r):
6767

6868
@skip_if_server_version_lt("7.0.0")
6969
@skip_if_redis_enterprise()
70-
@pytest.mark.onlynoncluster
7170
def test_eval_ro(self, r):
7271
r.set("a", "b")
7372
assert r.eval_ro("return redis.call('GET', KEYS[1])", 1, "a") == b"b"
@@ -157,7 +156,6 @@ def test_evalsha(self, r):
157156

158157
@skip_if_server_version_lt("7.0.0")
159158
@skip_if_redis_enterprise()
160-
@pytest.mark.onlynoncluster
161159
def test_evalsha_ro(self, r):
162160
r.set("a", "b")
163161
get_sha = r.script_load("return redis.call('GET', KEYS[1])")

0 commit comments

Comments
 (0)