Skip to content

Commit ae80708

Browse files
committed
Issue READONLY as part of the client connection
Fix: #1017
1 parent 01768da commit ae80708

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/redis/client.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ def connect
126126
call [:auth, password]
127127
end
128128
end
129+
130+
call [:readonly] if @options[:readonly]
129131
call [:select, db] if db != 0
130132
call [:client, :setname, @options[:id]] if @options[:id]
131133
@connector.check(self)

lib/redis/cluster/node.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ def build_clients(options)
7676
clients = options.map do |node_key, option|
7777
next if replica_disabled? && slave?(node_key)
7878

79+
option = option.merge(readonly: true) if slave?(node_key)
80+
7981
client = Client.new(option)
80-
client.call(%i[readonly]) if slave?(node_key)
8182
[node_key, client]
8283
end
8384

0 commit comments

Comments
 (0)