Class: Redis::Cluster::Option
- Inherits:
-
Object
- Object
- Redis::Cluster::Option
- Defined in:
- lib/redis/cluster/option.rb
Overview
Keep options for Redis Cluster Client
Constant Summary collapse
- DEFAULT_SCHEME =
'redis'
- SECURE_SCHEME =
'rediss'
- VALID_SCHEMES =
[DEFAULT_SCHEME, SECURE_SCHEME].freeze
Instance Method Summary collapse
- #add_node(host, port) ⇒ Object
-
#initialize(options) ⇒ Option
constructor
A new instance of Option.
- #per_node_key ⇒ Object
- #update_node(addrs) ⇒ Object
- #use_replica? ⇒ Boolean
Constructor Details
#initialize(options) ⇒ Option
Returns a new instance of Option.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/redis/cluster/option.rb', line 15 def initialize() = .dup node_addrs = .delete(:cluster) @node_opts = (node_addrs) @replica = .delete(:replica) == true @fixed_hostname = .delete(:fixed_hostname) add_common_node_option_if_needed(, @node_opts, :scheme) add_common_node_option_if_needed(, @node_opts, :username) add_common_node_option_if_needed(, @node_opts, :password) @options = end |
Instance Method Details
#add_node(host, port) ⇒ Object
44 45 46 |
# File 'lib/redis/cluster/option.rb', line 44 def add_node(host, port) @node_opts << { host: host, port: port } end |
#per_node_key ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/redis/cluster/option.rb', line 27 def per_node_key @node_opts.map do |opt| node_key = NodeKey.build_from_host_port(opt[:host], opt[:port]) = @options.merge(opt) = .merge(host: @fixed_hostname) if @fixed_hostname && !@fixed_hostname.empty? [node_key, ] end.to_h end |
#update_node(addrs) ⇒ Object
40 41 42 |
# File 'lib/redis/cluster/option.rb', line 40 def update_node(addrs) @node_opts = (addrs) end |
#use_replica? ⇒ Boolean
36 37 38 |
# File 'lib/redis/cluster/option.rb', line 36 def use_replica? @replica end |