forked from redis/ioredis
/
RedisOptions.ts
70 lines (67 loc) 路 1.82 KB
/
RedisOptions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { ISentinelConnectionOptions } from "../connectors/SentinelConnector";
import AbstractConnector from "../connectors/AbstractConnector";
import { IClusterOptions } from "../cluster/ClusterOptions";
import { ICommanderOptions } from "../commander";
export type ReconnectOnError = (err: Error) => boolean | 1 | 2;
export interface IRedisOptions
extends Partial<ISentinelConnectionOptions>,
Partial<ICommanderOptions>,
Partial<IClusterOptions> {
Connector?: typeof AbstractConnector;
retryStrategy?: (times: number) => number | void | null;
keepAlive?: number;
noDelay?: boolean;
connectionName?: string;
username?: string;
password?: string;
db?: number;
dropBufferSupport?: boolean;
autoResubscribe?: boolean;
autoResendUnfulfilledCommands?: boolean;
keyPrefix?: string;
reconnectOnError?: ReconnectOnError;
readOnly?: boolean;
stringNumbers?: boolean;
maxRetriesPerRequest?: number;
maxLoadingRetryTime?: number;
}
export const DEFAULT_REDIS_OPTIONS: IRedisOptions = {
// Connection
port: 6379,
host: "localhost",
family: 4,
connectTimeout: 10000,
retryStrategy: function (times) {
return Math.min(times * 50, 2000);
},
keepAlive: 0,
noDelay: true,
connectionName: null,
// Sentinel
sentinels: null,
name: null,
role: "master",
sentinelRetryStrategy: function (times) {
return Math.min(times * 10, 1000);
},
natMap: null,
enableTLSForSentinelMode: false,
updateSentinels: true,
// Status
username: null,
password: null,
db: 0,
// Others
dropBufferSupport: false,
enableOfflineQueue: true,
enableReadyCheck: true,
autoResubscribe: true,
autoResendUnfulfilledCommands: true,
lazyConnect: false,
keyPrefix: "",
reconnectOnError: null,
readOnly: false,
stringNumbers: false,
maxRetriesPerRequest: 20,
maxLoadingRetryTime: 10000,
};