Skip to content

Commit

Permalink
Issue READONLY as part of the client connection
Browse files Browse the repository at this point in the history
Fix: #1017
  • Loading branch information
byroot committed Jul 7, 2021
1 parent 01768da commit ae80708
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/redis/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion lib/redis/cluster/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ae80708

Please sign in to comment.