DNS Addresses and ports of known nodes in the cluster. If the server is in cluster mode the list can be partial, as the client will attempt to map out the cluster and find all nodes. If the server is in standalone mode, only nodes whose addresses were provided will be used by the client.
Optionalport?: numberIf port isn't supplied, 6379 will be used
OptionalclientAvailability Zone of the client. If ReadFrom strategy is AZAffinity or AZAffinityReplicasAndPrimary, this setting ensures that readonly commands are directed to nodes within the specified AZ if they exist.
// Example configuration for setting client availability zone and read strategy
configuration.clientAz = 'us-east-1a'; // Sets the client's availability zone
configuration.readFrom = 'AZAffinity'; // Directs read operations to nodes within the same AZ
Or
configuration.readFrom = 'AZAffinityReplicasAndPrimary'; // Directs read operations to any node (primary or replica) within the same AZ
OptionalclientClient name to be used for the client. Will be used with CLIENT SETNAME command during connection establishment.
OptionalconnectionStrategy used to determine how and when to reconnect, in case of connection failures.
The time between attempts grows exponentially, following the formula rand(0 ... factor * (exponentBase ^ N)), where N is the number of failed attempts,
and rand(...) applies a jitter of up to jitterPercent% to introduce randomness and reduce retry storms.
The client will attempt to reconnect indefinitely. Once the maximum value is reached, that will remain the time between retry attempts until a
reconnect attempt is successful.
If not set, a default backoff strategy will be used.
The exponent base configured for the strategy. Value must be an integer.
The multiplier that will be applied to the waiting time between each retry. This value is specified in milliseconds. Value must be an integer.
OptionaljitterPercent?: numberThe Jitter percent on the calculated duration. If not set, a default value will be used. Value is optional, and must be an integer.
Number of retry attempts that the client should perform when disconnected from the server, where the time between retries increases. Once the retries have reached the maximum value, the time between retries will remain constant until a reconnect attempt is succesful. Value must be an integer.
OptionalcredentialsCredentials for authentication process. If none are set, the client will not authenticate itself with the server.
OptionaldatabaseIndex of the logical database to connect to.
databases configuration (standalone) or cluster-databases configuration (cluster mode).// Connect to database 5
const config: BaseClientConfiguration = {
addresses: [{ host: 'localhost', port: 6379 }],
databaseId: 5
};
// Connect to a higher database ID (server will validate the limit)
const configHighDb: BaseClientConfiguration = {
addresses: [{ host: 'localhost', port: 6379 }],
databaseId: 100
};
OptionaldefaultDefault decoder when decoder is not set per command. If not set, 'Decoder.String' will be used.
OptionalinflightThe maximum number of concurrent requests allowed to be in-flight (sent but not yet completed). This limit is used to control the memory usage and prevent the client from overwhelming the server or getting stuck in case of a queue backlog. If not set, a default value of 1000 will be used.
OptionallazyEnables lazy connection mode, where physical connections to the server(s) are deferred until the first command is sent. This can reduce startup latency and allow for client creation in disconnected environments.
false – connections are established immediately during client creation.When lazyConnect is set to true, the client will not attempt to connect to the specified
nodes during initialization. Instead, connections will be established only when a command is
actually executed.
Note that the first command executed with lazy connections may experience additional latency
as it needs to establish the connection first. During this initial connection, the standard
request timeout does not apply yet - instead, the connection establishment is governed by
AdvancedBaseClientConfiguration::connectionTimeout. The request timeout (requestTimeout)
only begins counting after the connection has been successfully established. This behavior
can effectively increase the total time needed for the first command to complete.
This setting applies to both standalone and cluster modes. Note that if an operation is attempted and connection fails (e.g., unreachable nodes), errors will surface at that point.
OptionalprotocolSerialization protocol to be used.
If not set, RESP3 will be used.
OptionalreadThe client's read from strategy.
If not set, Primary will be used.
OptionalrequestThe duration in milliseconds that the client should wait for a request to complete. This duration encompasses sending the request, awaiting for a response from the server, and any required reconnection or retries. If the specified timeout is exceeded for a pending request, it will result in a timeout error. If not explicitly set, a default value of 250 milliseconds will be used. Value must be an integer.
OptionaluseTrue if communication with the cluster should use Transport Level Security. Should match the TLS configuration of the server/cluster, otherwise the connection attempt will fail.
Configuration settings for creating a client. Shared settings for standalone and cluster clients.
Remarks
The
BaseClientConfigurationinterface defines the foundational configuration options used when creating a client to connect to a Valkey server or cluster. It includes connection details, authentication, communication protocols, and various settings that influence the client's behavior and interaction with the server.Connection Details
addressesproperty to specify the hostnames and ports of the server(s) to connect to.lazyConnecttotrueto defer connection establishment until the first command is sent.Database Selection
databaseIdto specify which logical database to connect to (0-15 by default).Security Settings
useTLS. Should match the TLS configuration of the server/cluster, otherwise the connection attempt will fail. For advanced tls configuration, , see AdvancedBaseClientConfiguration.credentialsto authenticate with the server.Communication Settings
requestTimeoutto specify how long the client should wait for a request to complete.protocol.Client Identification
clientNameto identify the client connection.Read Strategy
readFromto specify the client's read strategy (e.g., primary, preferReplica, AZAffinity, AZAffinityReplicasAndPrimary).Availability Zone
clientAzto specify the client's availability zone, which can influence read operations when usingreadFrom: 'AZAffinity'orreadFrom: 'AZAffinityReplicasAndPrimary'`.Decoder Settings
defaultDecoderto specify how responses are decoded by default.Concurrency Control
inflightRequestsLimit.Reconnection Strategy
connectionBackoff.numberOfRetries: The maximum number of retry attempts with increasing delays.factor: A multiplier applied to the base delay between retries, specified in milliseconds (e.g.,500means a 500ms base delay).exponentBase: The exponential growth factor for delays (e.g.,2means the delay doubles with each retry).jitterPercent: An optional percentage of jitter to add to the delay (e.g.,30means the final delay will vary randomly between 70% and 130% of the calculated delay).Example