ioredis 5.9.1 → 5.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/built/Pipeline.js +8 -1
- package/built/autoPipelining.js +8 -1
- package/built/cluster/ClusterOptions.d.ts +21 -21
- package/built/cluster/ClusterSubscriberGroup.d.ts +1 -1
- package/built/cluster/ClusterSubscriberGroup.js +6 -1
- package/built/cluster/index.js +13 -3
- package/built/cluster/util.d.ts +2 -2
- package/built/connectors/SentinelConnector/index.d.ts +21 -21
- package/built/connectors/StandaloneConnector.d.ts +2 -2
- package/built/redis/RedisOptions.d.ts +33 -33
- package/built/utils/Commander.d.ts +2 -2
- package/package.json +1 -1
package/built/Pipeline.js
CHANGED
|
@@ -139,7 +139,14 @@ class Pipeline extends Commander_1.default {
|
|
|
139
139
|
cluster.handleError(commonError, this.leftRedirections, {
|
|
140
140
|
moved: function (_slot, key) {
|
|
141
141
|
_this.preferKey = key;
|
|
142
|
-
cluster.slots[errv[1]]
|
|
142
|
+
if (cluster.slots[errv[1]]) {
|
|
143
|
+
if (cluster.slots[errv[1]][0] !== key) {
|
|
144
|
+
cluster.slots[errv[1]] = [key];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
cluster.slots[errv[1]] = [key];
|
|
149
|
+
}
|
|
143
150
|
cluster._groupsBySlot[errv[1]] =
|
|
144
151
|
cluster._groupsIds[cluster.slots[errv[1]].join(";")];
|
|
145
152
|
cluster.refreshSlotsCache();
|
package/built/autoPipelining.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.executeWithAutoPipelining = exports.getFirstValueInFlattenedArray = expo
|
|
|
4
4
|
const lodash_1 = require("./utils/lodash");
|
|
5
5
|
const calculateSlot = require("cluster-key-slot");
|
|
6
6
|
const standard_as_callback_1 = require("standard-as-callback");
|
|
7
|
+
const commands_1 = require("@ioredis/commands");
|
|
7
8
|
exports.kExec = Symbol("exec");
|
|
8
9
|
exports.kCallbacks = Symbol("callbacks");
|
|
9
10
|
exports.notAllowedAutoPipelineCommands = [
|
|
@@ -118,9 +119,15 @@ function executeWithAutoPipelining(client, functionName, commandName, args, call
|
|
|
118
119
|
// Note that the first value in args may be a (possibly empty) array.
|
|
119
120
|
// ioredis will only flatten one level of the array, in the Command constructor.
|
|
120
121
|
const prefix = client.options.keyPrefix || "";
|
|
121
|
-
|
|
122
|
+
let slotKey = client.isCluster
|
|
122
123
|
? client.slots[calculateSlot(`${prefix}${getFirstValueInFlattenedArray(args)}`)].join(",")
|
|
123
124
|
: "main";
|
|
125
|
+
// When scaleReads is enabled, separate read and write commands into different pipelines
|
|
126
|
+
// so they can be routed to replicas and masters respectively
|
|
127
|
+
if (client.isCluster && client.options.scaleReads !== "master") {
|
|
128
|
+
const isReadOnly = (0, commands_1.exists)(commandName) && (0, commands_1.hasFlag)(commandName, "readonly");
|
|
129
|
+
slotKey += isReadOnly ? ":read" : ":write";
|
|
130
|
+
}
|
|
124
131
|
if (!client._autoPipelines.has(slotKey)) {
|
|
125
132
|
const pipeline = client.pipeline();
|
|
126
133
|
pipeline[exports.kExec] = false;
|
|
@@ -24,26 +24,26 @@ export interface ClusterOptions extends CommanderOptions {
|
|
|
24
24
|
*
|
|
25
25
|
* @default (times) => Math.min(100 + times * 2, 2000)
|
|
26
26
|
*/
|
|
27
|
-
clusterRetryStrategy?: (times: number, reason?: Error) => number | void | null;
|
|
27
|
+
clusterRetryStrategy?: ((times: number, reason?: Error) => number | void | null) | undefined;
|
|
28
28
|
/**
|
|
29
29
|
* See Redis class.
|
|
30
30
|
*
|
|
31
31
|
* @default true
|
|
32
32
|
*/
|
|
33
|
-
enableOfflineQueue?: boolean;
|
|
33
|
+
enableOfflineQueue?: boolean | undefined;
|
|
34
34
|
/**
|
|
35
35
|
* When enabled, ioredis only emits "ready" event when `CLUSTER INFO`
|
|
36
36
|
* command reporting the cluster is ready for handling commands.
|
|
37
37
|
*
|
|
38
38
|
* @default true
|
|
39
39
|
*/
|
|
40
|
-
enableReadyCheck?: boolean;
|
|
40
|
+
enableReadyCheck?: boolean | undefined;
|
|
41
41
|
/**
|
|
42
42
|
* Scale reads to the node with the specified role.
|
|
43
43
|
*
|
|
44
44
|
* @default "master"
|
|
45
45
|
*/
|
|
46
|
-
scaleReads?: NodeRole | Function;
|
|
46
|
+
scaleReads?: NodeRole | Function | undefined;
|
|
47
47
|
/**
|
|
48
48
|
* When a MOVED or ASK error is received, client will redirect the
|
|
49
49
|
* command to another node.
|
|
@@ -51,7 +51,7 @@ export interface ClusterOptions extends CommanderOptions {
|
|
|
51
51
|
*
|
|
52
52
|
* @default 16
|
|
53
53
|
*/
|
|
54
|
-
maxRedirections?: number;
|
|
54
|
+
maxRedirections?: number | undefined;
|
|
55
55
|
/**
|
|
56
56
|
* When an error is received when sending a command (e.g.
|
|
57
57
|
* "Connection is closed." when the target Redis node is down), client will retry
|
|
@@ -59,21 +59,21 @@ export interface ClusterOptions extends CommanderOptions {
|
|
|
59
59
|
*
|
|
60
60
|
* @default 100
|
|
61
61
|
*/
|
|
62
|
-
retryDelayOnFailover?: number;
|
|
62
|
+
retryDelayOnFailover?: number | undefined;
|
|
63
63
|
/**
|
|
64
64
|
* When a CLUSTERDOWN error is received, client will retry
|
|
65
65
|
* if `retryDelayOnClusterDown` is valid delay time (in ms).
|
|
66
66
|
*
|
|
67
67
|
* @default 100
|
|
68
68
|
*/
|
|
69
|
-
retryDelayOnClusterDown?: number;
|
|
69
|
+
retryDelayOnClusterDown?: number | undefined;
|
|
70
70
|
/**
|
|
71
71
|
* When a TRYAGAIN error is received, client will retry
|
|
72
72
|
* if `retryDelayOnTryAgain` is valid delay time (in ms).
|
|
73
73
|
*
|
|
74
74
|
* @default 100
|
|
75
75
|
*/
|
|
76
|
-
retryDelayOnTryAgain?: number;
|
|
76
|
+
retryDelayOnTryAgain?: number | undefined;
|
|
77
77
|
/**
|
|
78
78
|
* By default, this value is 0, which means when a `MOVED` error is received,
|
|
79
79
|
* the client will resend the command instantly to the node returned together with
|
|
@@ -83,20 +83,20 @@ export interface ClusterOptions extends CommanderOptions {
|
|
|
83
83
|
*
|
|
84
84
|
* @default 0
|
|
85
85
|
*/
|
|
86
|
-
retryDelayOnMoved?: number;
|
|
86
|
+
retryDelayOnMoved?: number | undefined;
|
|
87
87
|
/**
|
|
88
88
|
* The milliseconds before a timeout occurs while refreshing
|
|
89
89
|
* slots from the cluster.
|
|
90
90
|
*
|
|
91
91
|
* @default 1000
|
|
92
92
|
*/
|
|
93
|
-
slotsRefreshTimeout?: number;
|
|
93
|
+
slotsRefreshTimeout?: number | undefined;
|
|
94
94
|
/**
|
|
95
95
|
* The milliseconds between every automatic slots refresh.
|
|
96
96
|
*
|
|
97
97
|
* @default 5000
|
|
98
98
|
*/
|
|
99
|
-
slotsRefreshInterval?: number;
|
|
99
|
+
slotsRefreshInterval?: number | undefined;
|
|
100
100
|
/**
|
|
101
101
|
* Use sharded subscribers instead of a single subscriber.
|
|
102
102
|
*
|
|
@@ -105,13 +105,13 @@ export interface ClusterOptions extends CommanderOptions {
|
|
|
105
105
|
*
|
|
106
106
|
* @default false
|
|
107
107
|
*/
|
|
108
|
-
shardedSubscribers?: boolean;
|
|
108
|
+
shardedSubscribers?: boolean | undefined;
|
|
109
109
|
/**
|
|
110
110
|
* Passed to the constructor of `Redis`
|
|
111
111
|
*
|
|
112
112
|
* @default null
|
|
113
113
|
*/
|
|
114
|
-
redisOptions?: Omit<RedisOptions, "port" | "host" | "path" | "sentinels" | "retryStrategy" | "enableOfflineQueue" | "readOnly"
|
|
114
|
+
redisOptions?: Omit<RedisOptions, "port" | "host" | "path" | "sentinels" | "retryStrategy" | "enableOfflineQueue" | "readOnly"> | undefined;
|
|
115
115
|
/**
|
|
116
116
|
* By default, When a new Cluster instance is created,
|
|
117
117
|
* it will connect to the Redis cluster automatically.
|
|
@@ -120,13 +120,13 @@ export interface ClusterOptions extends CommanderOptions {
|
|
|
120
120
|
*
|
|
121
121
|
* @default false
|
|
122
122
|
*/
|
|
123
|
-
lazyConnect?: boolean;
|
|
123
|
+
lazyConnect?: boolean | undefined;
|
|
124
124
|
/**
|
|
125
125
|
* Discover nodes using SRV records
|
|
126
126
|
*
|
|
127
127
|
* @default false
|
|
128
128
|
*/
|
|
129
|
-
useSRVRecords?: boolean;
|
|
129
|
+
useSRVRecords?: boolean | undefined;
|
|
130
130
|
/**
|
|
131
131
|
* SRV records will be resolved via this function.
|
|
132
132
|
*
|
|
@@ -135,7 +135,7 @@ export interface ClusterOptions extends CommanderOptions {
|
|
|
135
135
|
*
|
|
136
136
|
* @default require('dns').resolveSrv
|
|
137
137
|
*/
|
|
138
|
-
resolveSrv?: DNSResolveSrvFunction;
|
|
138
|
+
resolveSrv?: DNSResolveSrvFunction | undefined;
|
|
139
139
|
/**
|
|
140
140
|
* Hostnames will be resolved to IP addresses via this function.
|
|
141
141
|
* This is needed when the addresses of startup nodes are hostnames instead
|
|
@@ -146,20 +146,20 @@ export interface ClusterOptions extends CommanderOptions {
|
|
|
146
146
|
*
|
|
147
147
|
* @default require('dns').lookup
|
|
148
148
|
*/
|
|
149
|
-
dnsLookup?: DNSLookupFunction;
|
|
150
|
-
natMap?: NatMap;
|
|
149
|
+
dnsLookup?: DNSLookupFunction | undefined;
|
|
150
|
+
natMap?: NatMap | undefined;
|
|
151
151
|
/**
|
|
152
152
|
* See Redis class.
|
|
153
153
|
*
|
|
154
154
|
* @default false
|
|
155
155
|
*/
|
|
156
|
-
enableAutoPipelining?: boolean;
|
|
156
|
+
enableAutoPipelining?: boolean | undefined;
|
|
157
157
|
/**
|
|
158
158
|
* See Redis class.
|
|
159
159
|
*
|
|
160
160
|
* @default []
|
|
161
161
|
*/
|
|
162
|
-
autoPipeliningIgnoredCommands?: string[];
|
|
162
|
+
autoPipeliningIgnoredCommands?: string[] | undefined;
|
|
163
163
|
/**
|
|
164
164
|
* Custom LUA commands
|
|
165
165
|
*/
|
|
@@ -167,6 +167,6 @@ export interface ClusterOptions extends CommanderOptions {
|
|
|
167
167
|
lua: string;
|
|
168
168
|
numberOfKeys?: number;
|
|
169
169
|
readOnly?: boolean;
|
|
170
|
-
}
|
|
170
|
+
}> | undefined;
|
|
171
171
|
}
|
|
172
172
|
export declare const DEFAULT_CLUSTER_OPTIONS: ClusterOptions;
|
|
@@ -112,12 +112,17 @@ class ClusterSubscriberGroup {
|
|
|
112
112
|
return Array.from(this.channels.values()).reduce((sum, array) => sum + array.length, 0);
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
|
-
* Disconnect all subscribers
|
|
115
|
+
* Disconnect all subscribers and clear some of the internal state.
|
|
116
116
|
*/
|
|
117
117
|
stop() {
|
|
118
118
|
for (const s of this.shardedSubscribers.values()) {
|
|
119
119
|
s.stop();
|
|
120
120
|
}
|
|
121
|
+
// Clear subscriber instances and pending operations.
|
|
122
|
+
// Channels are preserved for resubscription on reconnect.
|
|
123
|
+
this.pendingReset = null;
|
|
124
|
+
this.shardedSubscribers.clear();
|
|
125
|
+
this.subscriberToSlotsIndex.clear();
|
|
121
126
|
}
|
|
122
127
|
/**
|
|
123
128
|
* Start all not yet started subscribers
|
package/built/cluster/index.js
CHANGED
|
@@ -890,18 +890,28 @@ class Cluster extends Commander_1.default {
|
|
|
890
890
|
createShardedSubscriberGroup() {
|
|
891
891
|
this.subscriberGroupEmitter = new events_1.EventEmitter();
|
|
892
892
|
this.shardedSubscribers = new ClusterSubscriberGroup_1.default(this.subscriberGroupEmitter);
|
|
893
|
+
// Error handler used only for sharded-subscriber-triggered slots cache refreshes.
|
|
894
|
+
// Normal (non-subscriber) connections are created with lazyConnect: true and can
|
|
895
|
+
// become zombied. For sharded subscribers, a ClusterAllFailedError means
|
|
896
|
+
// we have lost all nodes from the subscriber perspective and must tear down.
|
|
897
|
+
const refreshSlotsCacheCallback = (err) => {
|
|
898
|
+
// Disconnect only when refreshing the slots cache fails with ClusterAllFailedError
|
|
899
|
+
if (err instanceof ClusterAllFailedError_1.default) {
|
|
900
|
+
this.disconnect(true);
|
|
901
|
+
}
|
|
902
|
+
};
|
|
893
903
|
this.subscriberGroupEmitter.on("-node", (redis, nodeKey) => {
|
|
894
904
|
this.emit("-node", redis, nodeKey);
|
|
895
|
-
this.refreshSlotsCache();
|
|
905
|
+
this.refreshSlotsCache(refreshSlotsCacheCallback);
|
|
896
906
|
});
|
|
897
907
|
this.subscriberGroupEmitter.on("subscriberConnectFailed", ({ delay, error }) => {
|
|
898
908
|
this.emit("error", error);
|
|
899
909
|
setTimeout(() => {
|
|
900
|
-
this.refreshSlotsCache();
|
|
910
|
+
this.refreshSlotsCache(refreshSlotsCacheCallback);
|
|
901
911
|
}, delay);
|
|
902
912
|
});
|
|
903
913
|
this.subscriberGroupEmitter.on("moved", () => {
|
|
904
|
-
this.refreshSlotsCache();
|
|
914
|
+
this.refreshSlotsCache(refreshSlotsCacheCallback);
|
|
905
915
|
});
|
|
906
916
|
this.subscriberGroupEmitter.on("-subscriber", () => {
|
|
907
917
|
this.emit("-subscriber");
|
package/built/cluster/util.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export declare type NodeRole = "master" | "slave" | "all";
|
|
|
5
5
|
export interface RedisOptions {
|
|
6
6
|
port: number;
|
|
7
7
|
host: string;
|
|
8
|
-
username?: string;
|
|
9
|
-
password?: string;
|
|
8
|
+
username?: string | undefined;
|
|
9
|
+
password?: string | undefined;
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
}
|
|
12
12
|
export interface SrvRecordsGroup {
|
|
@@ -9,46 +9,46 @@ import { NetStream } from "../../types";
|
|
|
9
9
|
interface AddressFromResponse {
|
|
10
10
|
port: string;
|
|
11
11
|
ip: string;
|
|
12
|
-
flags?: string;
|
|
12
|
+
flags?: string | undefined;
|
|
13
13
|
}
|
|
14
14
|
declare type PreferredSlaves = ((slaves: AddressFromResponse[]) => AddressFromResponse | null) | Array<{
|
|
15
15
|
port: string;
|
|
16
16
|
ip: string;
|
|
17
|
-
prio?: number;
|
|
17
|
+
prio?: number | undefined;
|
|
18
18
|
}> | {
|
|
19
19
|
port: string;
|
|
20
20
|
ip: string;
|
|
21
|
-
prio?: number;
|
|
21
|
+
prio?: number | undefined;
|
|
22
22
|
};
|
|
23
23
|
export { SentinelAddress, SentinelIterator };
|
|
24
24
|
export interface SentinelConnectionOptions {
|
|
25
25
|
/**
|
|
26
26
|
* Master group name of the Sentinel
|
|
27
27
|
*/
|
|
28
|
-
name?: string;
|
|
28
|
+
name?: string | undefined;
|
|
29
29
|
/**
|
|
30
30
|
* @default "master"
|
|
31
31
|
*/
|
|
32
|
-
role?: "master" | "slave";
|
|
33
|
-
tls?: ConnectionOptions;
|
|
34
|
-
sentinelUsername?: string;
|
|
35
|
-
sentinelPassword?: string;
|
|
36
|
-
sentinels?: Array<Partial<SentinelAddress
|
|
37
|
-
sentinelRetryStrategy?: (retryAttempts: number) => number | void | null;
|
|
38
|
-
sentinelReconnectStrategy?: (retryAttempts: number) => number | void | null;
|
|
39
|
-
preferredSlaves?: PreferredSlaves;
|
|
40
|
-
connectTimeout?: number;
|
|
41
|
-
disconnectTimeout?: number;
|
|
42
|
-
sentinelCommandTimeout?: number;
|
|
43
|
-
enableTLSForSentinelMode?: boolean;
|
|
44
|
-
sentinelTLS?: ConnectionOptions;
|
|
45
|
-
natMap?: NatMap;
|
|
46
|
-
updateSentinels?: boolean;
|
|
32
|
+
role?: "master" | "slave" | undefined;
|
|
33
|
+
tls?: ConnectionOptions | undefined;
|
|
34
|
+
sentinelUsername?: string | undefined;
|
|
35
|
+
sentinelPassword?: string | undefined;
|
|
36
|
+
sentinels?: Array<Partial<SentinelAddress>> | undefined;
|
|
37
|
+
sentinelRetryStrategy?: ((retryAttempts: number) => number | void | null) | undefined;
|
|
38
|
+
sentinelReconnectStrategy?: ((retryAttempts: number) => number | void | null) | undefined;
|
|
39
|
+
preferredSlaves?: PreferredSlaves | undefined;
|
|
40
|
+
connectTimeout?: number | undefined;
|
|
41
|
+
disconnectTimeout?: number | undefined;
|
|
42
|
+
sentinelCommandTimeout?: number | undefined;
|
|
43
|
+
enableTLSForSentinelMode?: boolean | undefined;
|
|
44
|
+
sentinelTLS?: ConnectionOptions | undefined;
|
|
45
|
+
natMap?: NatMap | undefined;
|
|
46
|
+
updateSentinels?: boolean | undefined;
|
|
47
47
|
/**
|
|
48
48
|
* @default 10
|
|
49
49
|
*/
|
|
50
|
-
sentinelMaxConnections?: number;
|
|
51
|
-
failoverDetector?: boolean;
|
|
50
|
+
sentinelMaxConnections?: number | undefined;
|
|
51
|
+
failoverDetector?: boolean | undefined;
|
|
52
52
|
}
|
|
53
53
|
export default class SentinelConnector extends AbstractConnector {
|
|
54
54
|
protected options: SentinelConnectionOptions;
|
|
@@ -6,8 +6,8 @@ import AbstractConnector, { ErrorEmitter } from "./AbstractConnector";
|
|
|
6
6
|
declare type TcpOptions = Pick<TcpNetConnectOpts, "port" | "host" | "family">;
|
|
7
7
|
declare type IpcOptions = Pick<IpcNetConnectOpts, "path">;
|
|
8
8
|
export declare type StandaloneConnectionOptions = Partial<TcpOptions & IpcOptions> & {
|
|
9
|
-
disconnectTimeout?: number;
|
|
10
|
-
tls?: ConnectionOptions;
|
|
9
|
+
disconnectTimeout?: number | undefined;
|
|
10
|
+
tls?: ConnectionOptions | undefined;
|
|
11
11
|
};
|
|
12
12
|
export default class StandaloneConnector extends AbstractConnector {
|
|
13
13
|
protected options: StandaloneConnectionOptions;
|
|
@@ -4,89 +4,89 @@ import { SentinelConnectionOptions } from "../connectors/SentinelConnector";
|
|
|
4
4
|
import { StandaloneConnectionOptions } from "../connectors/StandaloneConnector";
|
|
5
5
|
export declare type ReconnectOnError = (err: Error) => boolean | 1 | 2;
|
|
6
6
|
export interface CommonRedisOptions extends CommanderOptions {
|
|
7
|
-
Connector?: ConnectorConstructor;
|
|
8
|
-
retryStrategy?: (times: number) => number | void | null;
|
|
7
|
+
Connector?: ConnectorConstructor | undefined;
|
|
8
|
+
retryStrategy?: ((times: number) => number | void | null) | undefined;
|
|
9
9
|
/**
|
|
10
10
|
* If a command does not return a reply within a set number of milliseconds,
|
|
11
11
|
* a "Command timed out" error will be thrown.
|
|
12
12
|
*/
|
|
13
|
-
commandTimeout?: number;
|
|
13
|
+
commandTimeout?: number | undefined;
|
|
14
14
|
/**
|
|
15
15
|
* Enables client-side timeout protection for blocking commands when set
|
|
16
16
|
* to a positive number. If `blockingTimeout` is undefined, `0`, or
|
|
17
17
|
* negative (e.g. `-1`), the protection is disabled and no client-side
|
|
18
18
|
* timers are installed for blocking commands.
|
|
19
19
|
*/
|
|
20
|
-
blockingTimeout?: number;
|
|
20
|
+
blockingTimeout?: number | undefined;
|
|
21
21
|
/**
|
|
22
22
|
* Grace period (ms) added to blocking command timeouts. Only used when
|
|
23
23
|
* `blockingTimeout` is a positive number. Defaults to 100ms.
|
|
24
24
|
*/
|
|
25
|
-
blockingTimeoutGrace?: number;
|
|
25
|
+
blockingTimeoutGrace?: number | undefined;
|
|
26
26
|
/**
|
|
27
27
|
* If the socket does not receive data within a set number of milliseconds:
|
|
28
28
|
* 1. the socket is considered "dead" and will be destroyed
|
|
29
29
|
* 2. the client will reject any running commands (altought they might have been processed by the server)
|
|
30
30
|
* 3. the reconnect strategy will kick in (depending on the configuration)
|
|
31
31
|
*/
|
|
32
|
-
socketTimeout?: number;
|
|
32
|
+
socketTimeout?: number | undefined;
|
|
33
33
|
/**
|
|
34
34
|
* Enable/disable keep-alive functionality.
|
|
35
35
|
* @link https://nodejs.org/api/net.html#socketsetkeepaliveenable-initialdelay
|
|
36
36
|
* @default 0
|
|
37
37
|
*/
|
|
38
|
-
keepAlive?: number;
|
|
38
|
+
keepAlive?: number | undefined;
|
|
39
39
|
/**
|
|
40
40
|
* Enable/disable the use of Nagle's algorithm.
|
|
41
41
|
* @link https://nodejs.org/api/net.html#socketsetnodelaynodelay
|
|
42
42
|
* @default true
|
|
43
43
|
*/
|
|
44
|
-
noDelay?: boolean;
|
|
44
|
+
noDelay?: boolean | undefined;
|
|
45
45
|
/**
|
|
46
46
|
* Set the name of the connection to make it easier to identity the connection
|
|
47
47
|
* in client list.
|
|
48
48
|
* @link https://redis.io/commands/client-setname
|
|
49
49
|
*/
|
|
50
|
-
connectionName?: string;
|
|
50
|
+
connectionName?: string | undefined;
|
|
51
51
|
/**
|
|
52
52
|
* If true, skips setting library info via CLIENT SETINFO.
|
|
53
53
|
* @link https://redis.io/docs/latest/commands/client-setinfo/
|
|
54
54
|
* @default false
|
|
55
55
|
*/
|
|
56
|
-
disableClientInfo?: boolean;
|
|
56
|
+
disableClientInfo?: boolean | undefined;
|
|
57
57
|
/**
|
|
58
58
|
* Tag to append to the library name in CLIENT SETINFO (ioredis(tag)).
|
|
59
59
|
* @link https://redis.io/docs/latest/commands/client-setinfo/
|
|
60
60
|
* @default undefined
|
|
61
61
|
*/
|
|
62
|
-
clientInfoTag?: string;
|
|
62
|
+
clientInfoTag?: string | undefined;
|
|
63
63
|
/**
|
|
64
64
|
* If set, client will send AUTH command with the value of this option as the first argument when connected.
|
|
65
65
|
* This is supported since Redis 6.
|
|
66
66
|
*/
|
|
67
|
-
username?: string;
|
|
67
|
+
username?: string | undefined;
|
|
68
68
|
/**
|
|
69
69
|
* If set, client will send AUTH command with the value of this option when connected.
|
|
70
70
|
*/
|
|
71
|
-
password?: string;
|
|
71
|
+
password?: string | undefined;
|
|
72
72
|
/**
|
|
73
73
|
* Database index to use.
|
|
74
74
|
*
|
|
75
75
|
* @default 0
|
|
76
76
|
*/
|
|
77
|
-
db?: number;
|
|
77
|
+
db?: number | undefined;
|
|
78
78
|
/**
|
|
79
79
|
* When the client reconnects, channels subscribed in the previous connection will be
|
|
80
80
|
* resubscribed automatically if `autoResubscribe` is `true`.
|
|
81
81
|
* @default true
|
|
82
82
|
*/
|
|
83
|
-
autoResubscribe?: boolean;
|
|
83
|
+
autoResubscribe?: boolean | undefined;
|
|
84
84
|
/**
|
|
85
85
|
* Whether or not to resend unfulfilled commands on reconnect.
|
|
86
86
|
* Unfulfilled commands are most likely to be blocking commands such as `brpop` or `blpop`.
|
|
87
87
|
* @default true
|
|
88
88
|
*/
|
|
89
|
-
autoResendUnfulfilledCommands?: boolean;
|
|
89
|
+
autoResendUnfulfilledCommands?: boolean | undefined;
|
|
90
90
|
/**
|
|
91
91
|
* Whether or not to reconnect on certain Redis errors.
|
|
92
92
|
* This options by default is `null`, which means it should never reconnect on Redis errors.
|
|
@@ -108,29 +108,29 @@ export interface CommonRedisOptions extends CommanderOptions {
|
|
|
108
108
|
* ```
|
|
109
109
|
* @default null
|
|
110
110
|
*/
|
|
111
|
-
reconnectOnError?: ReconnectOnError | null;
|
|
111
|
+
reconnectOnError?: ReconnectOnError | null | undefined;
|
|
112
112
|
/**
|
|
113
113
|
* @default false
|
|
114
114
|
*/
|
|
115
|
-
readOnly?: boolean;
|
|
115
|
+
readOnly?: boolean | undefined;
|
|
116
116
|
/**
|
|
117
117
|
* When enabled, numbers returned by Redis will be converted to JavaScript strings instead of numbers.
|
|
118
118
|
* This is necessary if you want to handle big numbers (above `Number.MAX_SAFE_INTEGER` === 2^53).
|
|
119
119
|
* @default false
|
|
120
120
|
*/
|
|
121
|
-
stringNumbers?: boolean;
|
|
121
|
+
stringNumbers?: boolean | undefined;
|
|
122
122
|
/**
|
|
123
123
|
* How long the client will wait before killing a socket due to inactivity during initial connection.
|
|
124
124
|
* @default 10000
|
|
125
125
|
*/
|
|
126
|
-
connectTimeout?: number;
|
|
126
|
+
connectTimeout?: number | undefined;
|
|
127
127
|
/**
|
|
128
128
|
* This option is used internally when you call `redis.monitor()` to tell Redis
|
|
129
129
|
* to enter the monitor mode when the connection is established.
|
|
130
130
|
*
|
|
131
131
|
* @default false
|
|
132
132
|
*/
|
|
133
|
-
monitor?: boolean;
|
|
133
|
+
monitor?: boolean | undefined;
|
|
134
134
|
/**
|
|
135
135
|
* The commands that don't get a reply due to the connection to the server is lost are
|
|
136
136
|
* put into a queue and will be resent on reconnect (if allowed by the `retryStrategy` option).
|
|
@@ -141,21 +141,21 @@ export interface CommonRedisOptions extends CommanderOptions {
|
|
|
141
141
|
*
|
|
142
142
|
* @default 20
|
|
143
143
|
*/
|
|
144
|
-
maxRetriesPerRequest?: number | null;
|
|
144
|
+
maxRetriesPerRequest?: number | null | undefined;
|
|
145
145
|
/**
|
|
146
146
|
* @default 10000
|
|
147
147
|
*/
|
|
148
|
-
maxLoadingRetryTime?: number;
|
|
148
|
+
maxLoadingRetryTime?: number | undefined;
|
|
149
149
|
/**
|
|
150
150
|
* @default false
|
|
151
151
|
*/
|
|
152
|
-
enableAutoPipelining?: boolean;
|
|
152
|
+
enableAutoPipelining?: boolean | undefined;
|
|
153
153
|
/**
|
|
154
154
|
* @default []
|
|
155
155
|
*/
|
|
156
|
-
autoPipeliningIgnoredCommands?: string[];
|
|
157
|
-
offlineQueue?: boolean;
|
|
158
|
-
commandQueue?: boolean;
|
|
156
|
+
autoPipeliningIgnoredCommands?: string[] | undefined;
|
|
157
|
+
offlineQueue?: boolean | undefined;
|
|
158
|
+
commandQueue?: boolean | undefined;
|
|
159
159
|
/**
|
|
160
160
|
*
|
|
161
161
|
* By default, if the connection to Redis server has not been established, commands are added to a queue
|
|
@@ -166,7 +166,7 @@ export interface CommonRedisOptions extends CommanderOptions {
|
|
|
166
166
|
*
|
|
167
167
|
* @default true
|
|
168
168
|
*/
|
|
169
|
-
enableOfflineQueue?: boolean;
|
|
169
|
+
enableOfflineQueue?: boolean | undefined;
|
|
170
170
|
/**
|
|
171
171
|
* The client will sent an INFO command to check whether the server is still loading data from the disk (
|
|
172
172
|
* which happens when the server is just launched) when the connection is established, and only wait until
|
|
@@ -174,7 +174,7 @@ export interface CommonRedisOptions extends CommanderOptions {
|
|
|
174
174
|
*
|
|
175
175
|
* @default true
|
|
176
176
|
*/
|
|
177
|
-
enableReadyCheck?: boolean;
|
|
177
|
+
enableReadyCheck?: boolean | undefined;
|
|
178
178
|
/**
|
|
179
179
|
* When a Redis instance is initialized, a connection to the server is immediately established. Set this to
|
|
180
180
|
* true will delay the connection to the server until the first command is sent or `redis.connect()` is called
|
|
@@ -183,15 +183,15 @@ export interface CommonRedisOptions extends CommanderOptions {
|
|
|
183
183
|
*
|
|
184
184
|
* @default false
|
|
185
185
|
*/
|
|
186
|
-
lazyConnect?: boolean;
|
|
186
|
+
lazyConnect?: boolean | undefined;
|
|
187
187
|
/**
|
|
188
188
|
* @default undefined
|
|
189
189
|
*/
|
|
190
190
|
scripts?: Record<string, {
|
|
191
191
|
lua: string;
|
|
192
|
-
numberOfKeys?: number;
|
|
193
|
-
readOnly?: boolean;
|
|
194
|
-
}
|
|
192
|
+
numberOfKeys?: number | undefined;
|
|
193
|
+
readOnly?: boolean | undefined;
|
|
194
|
+
}> | undefined;
|
|
195
195
|
}
|
|
196
196
|
export declare type RedisOptions = CommonRedisOptions & SentinelConnectionOptions & StandaloneConnectionOptions;
|
|
197
197
|
export declare const DEFAULT_REDIS_OPTIONS: RedisOptions;
|
|
@@ -2,8 +2,8 @@ import Command from "../Command";
|
|
|
2
2
|
import { WriteableStream } from "../types";
|
|
3
3
|
import RedisCommander, { ClientContext } from "./RedisCommander";
|
|
4
4
|
export interface CommanderOptions {
|
|
5
|
-
keyPrefix?: string;
|
|
6
|
-
showFriendlyErrorStack?: boolean;
|
|
5
|
+
keyPrefix?: string | undefined;
|
|
6
|
+
showFriendlyErrorStack?: boolean | undefined;
|
|
7
7
|
}
|
|
8
8
|
declare class Commander<Context extends ClientContext = {
|
|
9
9
|
type: "default";
|