From ae807083c2e4737bece306cbc403f845a1a5962a Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Wed, 7 Jul 2021 11:30:02 +0200 Subject: [PATCH] Issue READONLY as part of the client connection Fix: #1017 --- lib/redis/client.rb | 2 ++ lib/redis/cluster/node.rb | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/redis/client.rb b/lib/redis/client.rb index 60631f29e..270eb11f4 100644 --- a/lib/redis/client.rb +++ b/lib/redis/client.rb @@ -126,6 +126,8 @@ def connect call [:auth, password] end end + + call [:readonly] if @options[:readonly] call [:select, db] if db != 0 call [:client, :setname, @options[:id]] if @options[:id] @connector.check(self) diff --git a/lib/redis/cluster/node.rb b/lib/redis/cluster/node.rb index 6040ea8ea..f3be41461 100644 --- a/lib/redis/cluster/node.rb +++ b/lib/redis/cluster/node.rb @@ -76,8 +76,9 @@ def build_clients(options) clients = options.map do |node_key, option| next if replica_disabled? && slave?(node_key) + option = option.merge(readonly: true) if slave?(node_key) + client = Client.new(option) - client.call(%i[readonly]) if slave?(node_key) [node_key, client] end