ioredis 5.0.2 → 5.0.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/Redis.d.ts
CHANGED
|
@@ -125,30 +125,20 @@ declare class Redis extends Commander {
|
|
|
125
125
|
* });
|
|
126
126
|
* ```
|
|
127
127
|
*/
|
|
128
|
-
monitor(callback
|
|
128
|
+
monitor(callback?: Callback<Redis>): Promise<Redis>;
|
|
129
129
|
/**
|
|
130
130
|
* Send a command to Redis
|
|
131
131
|
*
|
|
132
|
-
* This method is used internally
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* this command will be useful.
|
|
132
|
+
* This method is used internally and in most cases you should not
|
|
133
|
+
* use it directly. If you need to send a command that is not supported
|
|
134
|
+
* by the library, you can use the `call` method:
|
|
136
135
|
*
|
|
137
136
|
* ```js
|
|
138
137
|
* const redis = new Redis();
|
|
139
138
|
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
* });
|
|
144
|
-
* redis.sendCommand(get);
|
|
145
|
-
*
|
|
146
|
-
* // Use promise
|
|
147
|
-
* const set = new Command('set', ['foo', 'bar'], 'utf8');
|
|
148
|
-
* set.promise.then(function (result) {
|
|
149
|
-
* console.log(result);
|
|
150
|
-
* });
|
|
151
|
-
* redis.sendCommand(set);
|
|
139
|
+
* redis.call('set', 'foo', 'bar');
|
|
140
|
+
* // or
|
|
141
|
+
* redis.call(['set', 'foo', 'bar']);
|
|
152
142
|
* ```
|
|
153
143
|
*
|
|
154
144
|
* @ignore
|
package/built/Redis.js
CHANGED
|
@@ -135,8 +135,18 @@ class Redis extends Commander_1.default {
|
|
|
135
135
|
CONNECT_EVENT = "connect";
|
|
136
136
|
}
|
|
137
137
|
_this.stream = stream;
|
|
138
|
-
if (
|
|
139
|
-
stream.
|
|
138
|
+
if (options.noDelay) {
|
|
139
|
+
stream.setNoDelay(true);
|
|
140
|
+
}
|
|
141
|
+
// Node ignores setKeepAlive before connect, therefore we wait for the event:
|
|
142
|
+
// https://github.com/nodejs/node/issues/31663
|
|
143
|
+
if (typeof options.keepAlive === 'number') {
|
|
144
|
+
if (stream.connecting) {
|
|
145
|
+
stream.once(CONNECT_EVENT, () => stream.setKeepAlive(true, options.keepAlive));
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
stream.setKeepAlive(true, options.keepAlive);
|
|
149
|
+
}
|
|
140
150
|
}
|
|
141
151
|
if (stream.connecting) {
|
|
142
152
|
stream.once(CONNECT_EVENT, eventHandler.connectHandler(_this));
|
|
@@ -186,9 +196,6 @@ class Redis extends Commander_1.default {
|
|
|
186
196
|
stream.once("error", eventHandler.errorHandler(_this));
|
|
187
197
|
stream.once("close", eventHandler.closeHandler(_this));
|
|
188
198
|
}
|
|
189
|
-
if (options.noDelay) {
|
|
190
|
-
stream.setNoDelay(true);
|
|
191
|
-
}
|
|
192
199
|
const connectionReadyHandler = function () {
|
|
193
200
|
_this.removeListener("close", connectionCloseHandler);
|
|
194
201
|
resolve();
|
|
@@ -276,7 +283,8 @@ class Redis extends Commander_1.default {
|
|
|
276
283
|
monitor: true,
|
|
277
284
|
lazyConnect: false,
|
|
278
285
|
});
|
|
279
|
-
return (0, standard_as_callback_1.default)(new Promise(function (resolve) {
|
|
286
|
+
return (0, standard_as_callback_1.default)(new Promise(function (resolve, reject) {
|
|
287
|
+
monitorInstance.once("error", reject);
|
|
280
288
|
monitorInstance.once("monitoring", function () {
|
|
281
289
|
resolve(monitorInstance);
|
|
282
290
|
});
|
|
@@ -285,26 +293,16 @@ class Redis extends Commander_1.default {
|
|
|
285
293
|
/**
|
|
286
294
|
* Send a command to Redis
|
|
287
295
|
*
|
|
288
|
-
* This method is used internally
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
* this command will be useful.
|
|
296
|
+
* This method is used internally and in most cases you should not
|
|
297
|
+
* use it directly. If you need to send a command that is not supported
|
|
298
|
+
* by the library, you can use the `call` method:
|
|
292
299
|
*
|
|
293
300
|
* ```js
|
|
294
301
|
* const redis = new Redis();
|
|
295
302
|
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
* });
|
|
300
|
-
* redis.sendCommand(get);
|
|
301
|
-
*
|
|
302
|
-
* // Use promise
|
|
303
|
-
* const set = new Command('set', ['foo', 'bar'], 'utf8');
|
|
304
|
-
* set.promise.then(function (result) {
|
|
305
|
-
* console.log(result);
|
|
306
|
-
* });
|
|
307
|
-
* redis.sendCommand(set);
|
|
303
|
+
* redis.call('set', 'foo', 'bar');
|
|
304
|
+
* // or
|
|
305
|
+
* redis.call(['set', 'foo', 'bar']);
|
|
308
306
|
* ```
|
|
309
307
|
*
|
|
310
308
|
* @ignore
|
|
@@ -347,8 +345,7 @@ class Redis extends Commander_1.default {
|
|
|
347
345
|
command.reject(new Error("Stream isn't writeable and enableOfflineQueue options is false"));
|
|
348
346
|
return command.promise;
|
|
349
347
|
}
|
|
350
|
-
if (command.name === "quit" &&
|
|
351
|
-
this.offlineQueue.length === 0) {
|
|
348
|
+
if (command.name === "quit" && this.offlineQueue.length === 0) {
|
|
352
349
|
this.disconnect();
|
|
353
350
|
command.resolve(Buffer.from("OK"));
|
|
354
351
|
return command.promise;
|
|
@@ -88,11 +88,12 @@ class SentinelConnector extends AbstractConnector_1.default {
|
|
|
88
88
|
if (this.options.enableTLSForSentinelMode && this.options.tls) {
|
|
89
89
|
Object.assign(resolved, this.options.tls);
|
|
90
90
|
this.stream = (0, tls_1.connect)(resolved);
|
|
91
|
+
this.stream.once("secureConnect", this.initFailoverDetector.bind(this));
|
|
91
92
|
}
|
|
92
93
|
else {
|
|
93
94
|
this.stream = (0, net_1.createConnection)(resolved);
|
|
95
|
+
this.stream.once("connect", this.initFailoverDetector.bind(this));
|
|
94
96
|
}
|
|
95
|
-
this.stream.once("connect", () => this.initFailoverDetector());
|
|
96
97
|
this.stream.once("error", (err) => {
|
|
97
98
|
this.firstError = err;
|
|
98
99
|
});
|
package/built/index.d.ts
CHANGED
|
@@ -195,7 +195,7 @@ function readyHandler(self) {
|
|
|
195
195
|
self.setStatus("ready");
|
|
196
196
|
self.retryAttempts = 0;
|
|
197
197
|
if (self.options.monitor) {
|
|
198
|
-
self.call("monitor");
|
|
198
|
+
self.call("monitor").then(() => self.setStatus("monitoring"), (error) => self.emit("error", error));
|
|
199
199
|
const { sendCommand } = self;
|
|
200
200
|
self.sendCommand = function (command) {
|
|
201
201
|
if (Command_1.default.checkFlag("VALID_IN_MONITOR_MODE", command.name)) {
|
|
@@ -207,7 +207,6 @@ function readyHandler(self) {
|
|
|
207
207
|
self.once("close", function () {
|
|
208
208
|
delete self.sendCommand;
|
|
209
209
|
});
|
|
210
|
-
self.setStatus("monitoring");
|
|
211
210
|
return;
|
|
212
211
|
}
|
|
213
212
|
const finalSelect = self.prevCondition
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ioredis",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "A robust, performance-focused and full-featured Redis client for Node.js.",
|
|
5
5
|
"main": "./built/index.js",
|
|
6
6
|
"types": "./built/index.d.ts",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
58
58
|
"@semantic-release/git": "^10.0.1",
|
|
59
59
|
"@types/chai": "^4.3.0",
|
|
60
|
+
"@types/chai-as-promised": "^7.1.5",
|
|
60
61
|
"@types/debug": "^4.1.5",
|
|
61
62
|
"@types/lodash.defaults": "^4.2.6",
|
|
62
63
|
"@types/lodash.isarguments": "^3.1.6",
|