ioredis: new option maxRetriesPerRequest

This commit is contained in:
Piotr Roszatycki
2018-08-29 12:08:17 +02:00
parent 3be76f6b28
commit 8fb0189dd4
2 changed files with 12 additions and 0 deletions

View File

@@ -841,6 +841,17 @@ declare namespace IORedis {
* Fixed in: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/15858
*/
retryStrategy?(times: number): number | false;
/**
* By default, all pending commands will be flushed with an error every
* 20 retry attempts. That makes sure commands won't wait forever when
* the connection is down. You can change this behavior by setting
* `maxRetriesPerRequest`.
*
* Set maxRetriesPerRequest to `null` to disable this behavior, and
* every command will wait forever until the connection is alive again
* (which is the default behavior before ioredis v4).
*/
maxRetriesPerRequest?: number | null;
/**
* 1/true means reconnect, 2 means reconnect and resend failed command. Returning false will ignore
* the error and do nothing.

View File

@@ -46,6 +46,7 @@ new Redis({
password: 'auth',
db: 0,
retryStrategy() { return false; },
maxRetriesPerRequest: 20,
showFriendlyErrorStack: true,
tls: {
servername: 'tlsservername'