Class: RedisClient::Config
- Inherits:
-
Object
- Object
- RedisClient::Config
- Includes:
- Common
- Defined in:
- lib/redis_client/config.rb
Defined Under Namespace
Modules: Common
Constant Summary collapse
- DEFAULT_TIMEOUT =
1.0- DEFAULT_HOST =
"localhost"- DEFAULT_PORT =
6379- DEFAULT_USERNAME =
"default"- DEFAULT_DB =
0- DEFAULT_IDLE_TIMEOUT =
30.0
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#server_key ⇒ Object
readonly
Returns the value of attribute server_key.
Attributes included from Common
#circuit_breaker, #command_builder, #connect_timeout, #custom, #db, #driver, #driver_info, #id, #idle_timeout, #inherit_socket, #middlewares_stack, #protocol, #read_timeout, #ssl, #ssl_params, #write_timeout
Instance Method Summary collapse
-
#initialize(url: nil, host: nil, port: nil, path: nil, username: nil, password: nil, db: nil, **kwargs) ⇒ Config
constructor
A new instance of Config.
Methods included from Common
#build_lib_name, #connection_prelude, #new_client, #new_pool, #password, #resolved?, #retriable?, #retry_connecting?, #sentinel?, #server_url, #ssl_context, #username
Constructor Details
#initialize(url: nil, host: nil, port: nil, path: nil, username: nil, password: nil, db: nil, **kwargs) ⇒ Config
Returns a new instance of Config.
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/redis_client/config.rb', line 223 def initialize( url: nil, host: nil, port: nil, path: nil, username: nil, password: nil, db: nil, **kwargs ) if url url_config = URLConfig.new(url) kwargs = { ssl: url_config.ssl?, }.compact.merge(kwargs) db ||= url_config.db host ||= url_config.host port ||= url_config.port path ||= url_config.path username ||= url_config.username password ||= url_config.password end super(username: username, password: password, db: db, **kwargs) if @path = path @host = nil @port = nil else @host = host || DEFAULT_HOST @port = Integer(port || DEFAULT_PORT) end @server_key = [@path, @host, @port].freeze end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
221 222 223 |
# File 'lib/redis_client/config.rb', line 221 def host @host end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
221 222 223 |
# File 'lib/redis_client/config.rb', line 221 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
221 222 223 |
# File 'lib/redis_client/config.rb', line 221 def port @port end |
#server_key ⇒ Object (readonly)
Returns the value of attribute server_key.
221 222 223 |
# File 'lib/redis_client/config.rb', line 221 def server_key @server_key end |