Skip to content

Commit 1805e7d

Browse files
authored
fix: SCRIPT EXISTS must check all nodes (#182)
2 parents 7556cf2 + 241c6e6 commit 1805e7d

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

lib/redis_client/cluster/router.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ def send_script_command(method, command, args, &block)
255255
@node.call_all(method, command, args, &block).first
256256
when 'flush', 'load'
257257
@node.call_primaries(method, command, args, &block).first
258+
when 'exists'
259+
@node.call_all(method, command, args, &block).transpose.map { |arr| arr.any?(&:zero?) ? 0 : 1 }
258260
else assign_node(command).public_send(method, *args, command, &block)
259261
end
260262
end

test/redis_client/test_cluster.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ def test_dedicated_commands # rubocop:disable Metrics/CyclomaticComplexity, Metr
242242
{ command: %w[SCRIPT DEBUG NO], want: 'OK' },
243243
{ command: %w[SCRIPT FLUSH], want: 'OK' },
244244
{ command: %w[SCRIPT EXISTS b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c], want: [0] },
245+
{ command: %w[SCRIPT EXISTS 5b9fb3410653a731f8ddfeff39a0c061 31b6de18e43fe980ed07d8b0f5a8cabe], want: [0, 0] },
245246
{ command: %w[PUBSUB CHANNELS test-channel*], want: [] },
246247
{ command: %w[PUBSUB NUMSUB test-channel], want: { 'test-channel' => 0 } },
247248
{ command: %w[PUBSUB NUMPAT], want: 0 },

0 commit comments

Comments
 (0)