Configuration
public struct Configuration
A configuration object for creating a single connection to Redis.
-
The default port that Redis uses.
Declaration
Swift
public static var defaultPort: Int
-
The hostname of the connection address. If the address is a Unix socket, then it will be
nil
.Declaration
Swift
public var hostname: String? { get }
-
The port of the connection address. If the address is a Unix socket, then it will be
nil
.Declaration
Swift
public var port: Int? { get }
-
The password used to authenticate the connection.
Declaration
Swift
public let password: String?
-
The initial database index that the connection should use.
Declaration
Swift
public let initialDatabase: Int?
-
The logger prototype that will be used by the connection by default when generating logs.
Declaration
Swift
public let defaultLogger: Logger
-
Creates a new connection configuration with the provided details.
Throws
RedisConnection.Configuration.ValidationError
if invalid arguments are provided.Declaration
Swift
public init( address: SocketAddress, password: String? = nil, initialDatabase: Int? = nil, defaultLogger: Logger? = nil ) throws
Parameters
address
The socket address information to use for creating the Redis connection.
password
The optional password to authenticate the connection with. The default is
nil
.initialDatabase
The optional database index to initially connect to. The default is
nil
. Redis by default opens connections against index0
, so only set this value if the desired default is not0
.defaultLogger
The optional prototype logger to use as the default logger instance when generating logs from the connection. If one is not provided, one will be generated. See
RedisLogging.baseConnectionLogger
. -
Creates a new connection configuration with exact details.
Throws
NIO.SocketAddressError
if hostname resolution fails.RedisConnection.Configuration.ValidationError
if invalid arguments are provided.
Declaration
Swift
public init( hostname: String, port: Int = Self.defaultPort, password: String? = nil, initialDatabase: Int? = nil, defaultLogger: Logger? = nil ) throws
Parameters
hostname
The remote hostname to connect to.
port
The port that the Redis instance connects with. The default is
RedisConnection.Configuration.defaultPort
.password
The optional password to authenticate the connection with. The default is
nil
.initialDatabase
The optional database index to initially connect to. The default is
nil
. Redis by default opens connections against index0
, so only set this value if the desired default is not0
.defaultLogger
The optional prototype logger to use as the default logger instance when generating logs from the connection. If one is not provided, one will be generated. See
RedisLogging.baseConnectionLogger
. -
Creates a new connection configuration from the provided RFC 1808 URL formatted string.
This is a convenience initializer over creating a
Foundation.URL
directly and passing it to the overloaded initializer.The string is expected to match the RFC 1808 format.
An example string:
redis://:password@localhost:6379/3
For more details, see the
Configuration.init(url:)
overload that accepts aFoundation.URL
.Throws
RedisConnection.Configuration.ValidationError
if required URL components are invalid or missing.NIO.SocketAddressError
if hostname resolution fails.
Declaration
Swift
public init(url string: String, defaultLogger: Logger? = nil) throws
Parameters
string
The URL formatted string.
defaultLogger
The optional prototype logger to use as the default logger instance when generating logs from the connection. If one is not provided, one will be generated. See
RedisLogging.baseConnectionLogger
. -
Creates a new connection configuration from the provided URL object.
The
scheme
andhost
are the only properties that need to be established.Invariant
Theport
property is optional, with theRedisConnection.Configuration.defaultPort
being used by default.Invariant
password
is only required if the Redis instance specifies a password is required. This will not be detected until trying to establish a connection with this configuration.Invariant
To set the default selected database index, provide the index as thelastPathComponent
of theFoundation.URL
.Requires
The URL must use theredis://
scheme.Throws
RedisConnection.Configuration.ValidationError
if required URL components are invalid or missing.NIO.SocketAddressError
if hostname resolution fails.
Declaration
Swift
public init(url: URL, defaultLogger: Logger? = nil) throws
Parameters
url
The URL to use to resolve and authenticate the remote connection.
defaultLogger
The optional prototype logger to use as the default logger instance when generating logs from the connection. If one is not provided, one will be generated. See
RedisLogging.baseConnectionLogger
. -
Undocumented
See moreDeclaration
Swift
public struct ValidationError : LocalizedError, Equatable