class Redis
def initialize(options = {})
-
(Redis)
- a new client instance
Options Hash:
(**options)
-
:sentinels
(Array
) -- List of sentinels to contact -
:name
(String
) -- The name of the server group to connect to. -
:inherit_socket
(Boolean
) -- Whether to use socket in forked process or not -
:reconnect_attempts
(Integer, Array
) -- Number of attempts trying to connect, -
:id
(String
) -- ID for the client connection, assigns name to current connection by sending -
:driver
(Symbol
) -- Driver to use, currently supported: `:ruby`, `:hiredis` -
:db
(Integer
) -- Database to select after connect and on reconnects -
:password
(String
) -- Password to authenticate against server -
:username
(String
) -- Username to authenticate against server -
:connect_timeout
(Float
) -- timeout for initial connect in seconds -
:timeout
(Float
) -- timeout in seconds -
:path
(String
) -- path to server socket (overrides host and port) -
:port
(Integer
) -- server port -
:host
(String
) -- server hostname -
:url
(String
) -- a Redis URL, for a TCP connection:
Parameters:
-
options
(Hash
) --
def initialize(options = {}) @monitor = Monitor.new @options = options.dup @options[:reconnect_attempts] = 1 unless @options.key?(:reconnect_attempts) if ENV["REDIS_URL"] && SERVER_URL_OPTIONS.none? { |o| @options.key?(o) } @options[:url] = ENV["REDIS_URL"] end inherit_socket = @options.delete(:inherit_socket) @subscription_client = nil @client = initialize_client(@options) @client.inherit_socket! if inherit_socket end