Interface RedisClientOptions<M, F, S, RESP, TYPE_MAPPING, SocketOptions>

interface RedisClientOptions<M, F, S, RESP, TYPE_MAPPING, SocketOptions> {
    RESP: undefined | RESP;
    clientInfoTag?: string;
    clientSideCache?: ClientSideCacheProvider | ClientSideCacheConfig;
    commandOptions?: CommandOptions<TYPE_MAPPING>;
    commandsQueueMaxLength?: number;
    credentialsProvider?: CredentialsProvider;
    database?: number;
    disableClientInfo?: boolean;
    disableOfflineQueue?: boolean;
    emitInvalidate?: boolean;
    functions?: F;
    maintEndpointType?: MovingEndpointType;
    maintNotifications?: "disabled" | "enabled" | "auto";
    maintRelaxedCommandTimeout?: number;
    maintRelaxedSocketTimeout?: number;
    modules?: M;
    name?: string;
    password?: string;
    pingInterval?: number;
    readonly?: boolean;
    scripts?: S;
    socket?: SocketOptions;
    url?: string;
    username?: string;
}

Type Parameters

Hierarchy (view full)

Properties

RESP: undefined | RESP

Specifies the Redis Serialization Protocol version to use. RESP3 is the default (value 3), while RESP2 (value 2) remains available for compatibility. RESP3 provides additional data types and features introduced in Redis 6.0.

clientInfoTag?: string

Tag to append to library name that is sent to the Redis server

Client Side Caching configuration.

Enables Redis Servers and Clients to work together to cache results from commands sent to a server. The server will notify the client when cached results are no longer valid.

Note: Client Side Caching is only supported with RESP3.

Example: Anonymous cache configuration

const client = createClient({
RESP: 3,
clientSideCache: {
ttl: 0,
maxEntries: 0,
evictPolicy: "LRU"
}
});

Example: Using a controllable cache

const cache = new BasicClientSideCache({
ttl: 0,
maxEntries: 0,
evictPolicy: "LRU"
});
const client = createClient({
RESP: 3,
clientSideCache: cache
});
commandOptions?: CommandOptions<TYPE_MAPPING>

Default command options to be applied to all commands executed through this client.

These options can be overridden on a per-command basis when calling specific commands.

Example: Setting default command options

const client = createClient({
commandOptions: {
asap: true,
typeMapping: {
// Custom type mapping configuration
}
}
});
commandsQueueMaxLength?: number

Maximum length of the client's internal command queue

credentialsProvider?: CredentialsProvider

Provides credentials for authentication. Can be set directly or will be created internally if username/password are provided instead. If both are supplied, this credentialsProvider takes precedence over username/password.

database?: number

Redis database number (see SELECT command)

disableClientInfo?: boolean

If set to true, disables sending client identifier (user-agent like message) to the redis server

disableOfflineQueue?: boolean

When true, commands are rejected when the client is reconnecting. When false, commands are queued for execution after reconnection.

emitInvalidate?: boolean

When set to true, client tracking is turned on and the client emits invalidate events when it receives invalidation messages from the redis server. Mutually exclusive with clientSideCache option.

functions?: F
maintEndpointType?: MovingEndpointType

Controls how the client requests the endpoint to reconnect to during a MOVING notification in Redis Enterprise maintenance.

  • auto: If the connection is opened to a name or IP address that is from/resolves to a reserved private IP range, request an internal endpoint (e.g., internal-ip), otherwise an external one. If TLS is enabled, then request a FQDN.
  • internal-ip: Enforce requesting the internal IP.
  • internal-fqdn: Enforce requesting the internal FQDN.
  • external-ip: Enforce requesting the external IP address.
  • external-fqdn: Enforce requesting the external FQDN.
  • none: Used to request a null endpoint, which tells the client to reconnect based on its current config

The default is auto.

maintNotifications?: "disabled" | "enabled" | "auto"

Controls how the client handles Redis Enterprise maintenance push notifications.

  • disabled: The feature is not used by the client.
  • enabled: The client attempts to enable the feature on the server. If the server responds with an error, the connection is interrupted.
  • auto: The client attempts to enable the feature on the server. If the server returns an error, the client disables the feature and continues.

The default is auto.

maintRelaxedCommandTimeout?: number

Specifies a more relaxed timeout (in milliseconds) for commands during a maintenance window. This helps minimize command timeouts during maintenance. Timeouts during maintenance period result in a CommandTimeoutDuringMaintenance error.

The default is 10000

maintRelaxedSocketTimeout?: number

Specifies a more relaxed timeout (in milliseconds) for the socket during a maintenance window. This helps minimize socket timeouts during maintenance. Timeouts during maintenance period result in a SocketTimeoutDuringMaintenance error.

The default is 10000

modules?: M
name?: string

Client name (see CLIENT SETNAME)

password?: string

ACL password or the old "--requirepass" password

pingInterval?: number

Send PING command at interval (in ms). Useful with Redis deployments that do not honor TCP Keep-Alive.

readonly?: boolean

Connect in READONLY mode

scripts?: S
socket?: SocketOptions

Socket connection properties

url?: string

redis[s]://[[username][:password]@][host][:port][/db-number] See redis and rediss IANA registration for more details

username?: string

ACL username (see ACL guide)

Generated using TypeDoc