UNPKG

75.1 kBTypeScriptView Raw
1// Type definitions for ioredis 4.17
2// Project: https://github.com/luin/ioredis
3// Definitions by: York Yao <https://github.com/plantain-00>
4// Christopher Eck <https://github.com/chrisleck>
5// Yoga Aliarham <https://github.com/aliarham11>
6// Ebrahim <https://github.com/br8h>
7// Whemoon Jang <https://github.com/palindrom615>
8// Francis Gulotta <https://github.com/reconbot>
9// Dmitry Motovilov <https://github.com/funthing>
10// Oleg Repin <https://github.com/iamolegga>
11// Ting-Wai To <https://github.com/tingwai-to>
12// Alex Petty <https://github.com/pettyalex>
13// Simon Schick <https://github.com/SimonSchick>
14// Tianlin <https://github.com/tianlinle>
15// Demian Rodriguez <https://github.com/demian85>
16// Andrew Lavers <https://github.com/alavers>
17// Claudiu Ceia <https://github.com/ClaudiuCeia>
18// Asyrique <https://github.com/asyrique>
19// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
20// TypeScript Version: 2.8
21
22/* =================== USAGE ===================
23 import * as Redis from "ioredis";
24 const redis = new Redis();
25 =============================================== */
26
27/// <reference types="node" />
28
29import { ConnectionOptions } from 'tls';
30import { Readable } from 'stream';
31import { EventEmitter } from 'events';
32
33interface RedisStatic {
34 new (port?: number, host?: string, options?: IORedis.RedisOptions): IORedis.Redis;
35 new (host?: string, options?: IORedis.RedisOptions): IORedis.Redis;
36 new (options?: IORedis.RedisOptions): IORedis.Redis;
37 (port?: number, host?: string, options?: IORedis.RedisOptions): IORedis.Redis;
38 (host?: string, options?: IORedis.RedisOptions): IORedis.Redis;
39 (options?: IORedis.RedisOptions): IORedis.Redis;
40 Cluster: IORedis.ClusterStatic;
41 Command: typeof Command;
42}
43
44declare var IORedis: RedisStatic;
45export = IORedis;
46
47declare class Commander {
48 getBuiltinCommands(): string[];
49 createBuiltinCommand(commandName: string): {};
50 defineCommand(
51 name: string,
52 definition: {
53 numberOfKeys?: number;
54 lua?: string;
55 },
56 ): void;
57 sendCommand(): void;
58}
59
60interface CommandOptions {
61 replyEncoding?: string | null;
62 errorStack?: string;
63 keyPrefix?: string;
64}
65declare class Command {
66 isCustomCommand: boolean;
67 args: IORedis.ValueType[];
68 getSlot(): number | null;
69 getKeys(): Array<string | Buffer>;
70 constructor(
71 name: string,
72 args: IORedis.ValueType[],
73 opts?: CommandOptions,
74 callback?: (err: null, result: any) => void,
75 );
76 static setArgumentTransformer(name: string, fn: (args: IORedis.ValueType[]) => IORedis.ValueType[]): void;
77 static setReplyTransformer(name: string, fn: (result: any) => any): void;
78}
79
80// For backwards compatibility
81type _Command = typeof Command;
82
83declare namespace IORedis {
84 type BooleanResponse = 1 | 0;
85 type Callback<T> = (err: Error | null, res: T) => void;
86 type KeyType = string | Buffer;
87 type ValueType = string | Buffer | number | any[];
88
89 interface OverloadedCommand<T, U> {
90 (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb: Callback<U>): void;
91 (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, cb: Callback<U>): void;
92 (arg1: T, arg2: T, arg3: T, arg4: T, cb: Callback<U>): void;
93 (arg1: T, arg2: T, arg3: T, cb: Callback<U>): void;
94 (arg1: T, arg2: T, cb: Callback<U>): void;
95 (arg1: T | T[], cb: Callback<U>): void;
96 (cb: Callback<U>): void;
97 (...args: T[]): Promise<U>;
98 (arg1: T[]): Promise<U>;
99 }
100
101 interface OverloadedListCommand<T, U> {
102 (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb: Callback<U>): void;
103 (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, cb: Callback<U>): void;
104 (arg1: T, arg2: T, arg3: T, arg4: T, cb: Callback<U>): void;
105 (arg1: T, arg2: T, arg3: T, cb: Callback<U>): void;
106 (arg1: T, arg2: T, cb: Callback<U>): void;
107 (arg1: T | T[], cb: Callback<U>): void;
108 (...args: T[]): Promise<U>;
109 (arg1: T[]): Promise<U>;
110 }
111
112 interface OverloadedBlockingListCommand<T, U> {
113 (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, timeout: number, cb: Callback<U>): void;
114 (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, timeout: number, cb: Callback<U>): void;
115 (arg1: T, arg2: T, arg3: T, arg4: T, timeout: number, cb: Callback<U>): void;
116 (arg1: T, arg2: T, arg3: T, timeout: number, cb: Callback<U>): void;
117 (arg1: T, arg2: T, timeout: number, cb: Callback<U>): void;
118 (arg1: T, timeout: number, cb: Callback<U>): void;
119 (arg1: Array<T | number>, cb: Callback<U>): void;
120 (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, timeout: number): Promise<U>;
121 (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, timeout: number): Promise<U>;
122 (arg1: T, arg2: T, arg3: T, arg4: T, timeout: number): Promise<U>;
123 (arg1: T, arg2: T, arg3: T, timeout: number): Promise<U>;
124 (arg1: T, arg2: T, timeout: number): Promise<U>;
125 (arg1: T, timeout: number): Promise<U>;
126 (arg1: Array<T | number>): Promise<U>;
127 (...args: Array<T | number>): Promise<U>;
128 }
129
130 interface OverloadedSubCommand<T, U> {
131 (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb: Callback<U>): void;
132 (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, cb: Callback<U>): void;
133 (arg1: T, arg2: T, arg3: T, arg4: T, cb: Callback<U>): void;
134 (arg1: T, arg2: T, arg3: T, cb: Callback<U>): void;
135 (arg1: T, arg2: T | T[], cb: Callback<U>): void;
136 (arg1: T | T[], cb: Callback<U>): void;
137 (...args: T[]): Promise<U>;
138 (arg1: T[]): Promise<U>;
139 }
140
141 interface OverloadedKeyCommand<T, U> {
142 (key: KeyType, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb: Callback<U>): void;
143 (key: KeyType, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, cb: Callback<U>): void;
144 (key: KeyType, arg1: T, arg2: T, arg3: T, arg4: T, cb: Callback<U>): void;
145 (key: KeyType, arg1: T, arg2: T, arg3: T, cb: Callback<U>): void;
146 (key: KeyType, arg1: T, arg2: T, cb: Callback<U>): void;
147 (key: KeyType, arg1: T | T[], cb: Callback<U>): void;
148 (key: KeyType, ...args: T[]): Promise<U>;
149 (key: KeyType, arg1: T[]): Promise<U>;
150 }
151
152 interface OverloadedHashCommand<T, U> {
153 (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb: Callback<U>): void;
154 (arg1: T, arg2: T, arg3: T, arg4: T, cb: Callback<U>): void;
155 (arg1: T, arg2: T, cb: Callback<U>): void;
156 (data: T[] | { [key: string]: T } | Map<string, T>, cb: Callback<U>): void;
157 (data: T[] | { [key: string]: T } | Map<string, T>): Promise<U>;
158 (...args: T[]): Promise<U>;
159 }
160
161 interface OverloadedKeyedHashCommand<T, U> {
162 (key: KeyType, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb: Callback<U>): void;
163 (key: KeyType, arg1: T, arg2: T, arg3: T, arg4: T, cb: Callback<U>): void;
164 (key: KeyType, arg1: T, arg2: T, cb: Callback<U>): void;
165 (key: KeyType, data: T[] | { [key: string]: T } | Map<string, ValueType>, cb: Callback<U>): void;
166 (key: KeyType, data: T[] | { [key: string]: T } | Map<string, ValueType>): Promise<U>;
167 (key: KeyType, ...args: T[]): Promise<U>;
168 }
169
170 interface OverloadedEvalCommand<T, U> {
171 (script: string, numKeys: number, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb: Callback<U>): void;
172 (script: string, numKeys: number, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, cb: Callback<U>): void;
173 (script: string, numKeys: number, arg1: T, arg2: T, arg3: T, arg4: T, cb: Callback<U>): void;
174 (script: string, numKeys: number, arg1: T, arg2: T, arg3: T, cb: Callback<U>): void;
175 (script: string, numKeys: number, arg1: T, arg2: T, cb: Callback<U>): void;
176 (script: string, numKeys: number, arg1: T | T[], cb: Callback<U>): void;
177 (script: string, numKeys: number, ...args: T[]): Promise<U>;
178 (script: string, numKeys: number, arg1: T[]): Promise<U>;
179 // This overload exists specifically to retain compatibility to `redlock`
180 // All arguments are by default flattened, declaring all possible permuatations
181 // would be unreasonable (and probably impossible)
182 (args: ValueType[], callback?: Callback<any>): any;
183 }
184
185 interface OverloadedScanCommand<T, U> {
186 (key: string, cursor: number, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb: Callback<U>): void;
187 (key: string, cursor: number, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, cb: Callback<U>): void;
188 (key: string, cursor: number, arg1: T, arg2: T, arg3: T, arg4: T, cb: Callback<U>): void;
189 (key: string, cursor: number, arg1: T, arg2: T, arg3: T, cb: Callback<U>): void;
190 (key: string, cursor: number, arg1: T, arg2: T, cb: Callback<U>): void;
191 (key: string, cursor: number, arg1: T | T[], cb: Callback<U>): void;
192 (key: string, cursor: number, cb: Callback<U>): void;
193 (key: string, cursor: number, ...args: T[]): Promise<U>;
194 (key: string, cursor: number, arg1: T[]): Promise<U>;
195 }
196
197 type Command = _Command;
198
199 interface Commands {
200 bitcount(key: KeyType, callback: Callback<number>): void;
201 bitcount(key: KeyType, start: number, end: number, callback: (err: Error, res: number) => void): void;
202 bitcount(key: KeyType): Promise<number>;
203 bitcount(key: KeyType, start: number, end: number): Promise<number>;
204
205 get(key: KeyType, callback: Callback<string | null>): void;
206 get(key: KeyType): Promise<string | null>;
207
208 getBuffer(key: KeyType, callback: Callback<Buffer>): void;
209 getBuffer(key: KeyType): Promise<Buffer>;
210
211 set(
212 key: KeyType,
213 value: ValueType,
214 expiryMode?: string | any[],
215 time?: number | string,
216 setMode?: number | string,
217 ): Promise<Ok | null>;
218
219 set(key: KeyType, value: ValueType, callback: Callback<Ok>): void;
220 set(key: KeyType, value: ValueType, setMode: string | any[], callback: Callback<Ok | null>): void;
221 set(key: KeyType, value: ValueType, expiryMode: string, time: number | string, callback: Callback<Ok>): void;
222 set(
223 key: KeyType,
224 value: ValueType,
225 expiryMode: string,
226 time: number | string,
227 setMode: number | string,
228 callback: Callback<Ok | null>,
229 ): void;
230
231 setBuffer(
232 key: KeyType,
233 value: ValueType,
234 expiryMode?: string | any[],
235 time?: number | string,
236 setMode?: number | string,
237 ): Promise<Buffer>;
238
239 setBuffer(key: KeyType, value: ValueType, callback: Callback<Buffer>): void;
240 setBuffer(key: KeyType, value: ValueType, setMode: string, callback: Callback<Buffer>): void;
241 setBuffer(key: KeyType, value: ValueType, expiryMode: string, time: number, callback: Callback<Buffer>): void;
242 setBuffer(
243 key: KeyType,
244 value: ValueType,
245 expiryMode: string,
246 time: number | string,
247 setMode: number | string,
248 callback: Callback<Buffer>,
249 ): void;
250
251 setnx(key: KeyType, value: ValueType, callback: Callback<BooleanResponse>): void;
252 setnx(key: KeyType, value: ValueType): Promise<BooleanResponse>;
253
254 setex(key: KeyType, seconds: number, value: ValueType, callback: Callback<Ok>): void;
255 setex(key: KeyType, seconds: number, value: ValueType): Promise<Ok>;
256
257 psetex(key: KeyType, milliseconds: number, value: ValueType, callback: Callback<Ok>): void;
258 psetex(key: KeyType, milliseconds: number, value: ValueType): Promise<Ok>;
259
260 append(key: KeyType, value: ValueType, callback: Callback<number>): void;
261 append(key: KeyType, value: ValueType): Promise<number>;
262
263 strlen(key: KeyType, callback: Callback<number>): void;
264 strlen(key: KeyType): Promise<number>;
265
266 del: OverloadedListCommand<KeyType, number>;
267
268 unlink: OverloadedListCommand<KeyType, number>;
269
270 exists(...keys: KeyType[]): Promise<number>;
271 exists(key: KeyType, callback: Callback<number>): void;
272
273 setbit(key: KeyType, offset: number, value: ValueType, callback: Callback<number>): void;
274 setbit(key: KeyType, offset: number, value: ValueType): Promise<number>;
275
276 getbit(key: KeyType, offset: number, callback: Callback<number>): void;
277 getbit(key: KeyType, offset: number): Promise<number>;
278
279 setrange(key: KeyType, offset: number, value: ValueType, callback: Callback<number>): void;
280 setrange(key: KeyType, offset: number, value: ValueType): Promise<number>;
281
282 getrange(key: KeyType, start: number, end: number, callback: Callback<string>): void;
283 getrange(key: KeyType, start: number, end: number): Promise<string>;
284
285 getrangeBuffer(key: KeyType, start: number, end: number, callback: Callback<Buffer>): void;
286 getrangeBuffer(key: KeyType, start: number, end: number): Promise<Buffer>;
287
288 substr(key: KeyType, start: number, end: number, callback: Callback<string>): void;
289 substr(key: KeyType, start: number, end: number): Promise<string>;
290
291 incr(key: KeyType, callback: Callback<number>): void;
292 incr(key: KeyType): Promise<number>;
293
294 decr(key: KeyType, callback: Callback<number>): void;
295 decr(key: KeyType): Promise<number>;
296
297 mget: OverloadedListCommand<KeyType, Array<string | null>>;
298
299 rpush: OverloadedKeyCommand<ValueType, number>;
300 rpushBuffer: OverloadedKeyCommand<Buffer, number>;
301
302 lpush: OverloadedKeyCommand<ValueType, number>;
303 lpushBuffer: OverloadedKeyCommand<Buffer, number>;
304
305 rpushx: OverloadedKeyCommand<ValueType, number>;
306
307 lpushx: OverloadedKeyCommand<ValueType, number>;
308
309 linsert(
310 key: KeyType,
311 direction: 'BEFORE' | 'AFTER',
312 pivot: string,
313 value: ValueType,
314 callback: Callback<number>,
315 ): void;
316 linsert(key: KeyType, direction: 'BEFORE' | 'AFTER', pivot: string, value: ValueType): Promise<number>;
317
318 rpop(key: KeyType, callback: Callback<string>): void;
319 rpop(key: KeyType): Promise<string>;
320
321 lpop(key: KeyType, callback: Callback<string>): void;
322 lpop(key: KeyType): Promise<string>;
323
324 lpopBuffer(key: KeyType, callback: Callback<Buffer>): void;
325 lpopBuffer(key: KeyType): Promise<Buffer>;
326
327 brpop: OverloadedBlockingListCommand<KeyType, [string, string]>;
328
329 blpop: OverloadedBlockingListCommand<KeyType, [string, string]>;
330
331 brpoplpush(source: string, destination: string, timeout: number, callback: Callback<string>): void;
332 brpoplpush(source: string, destination: string, timeout: number): Promise<string>;
333
334 llen(key: KeyType, callback: Callback<number>): void;
335 llen(key: KeyType): Promise<number>;
336
337 lindex(key: KeyType, index: number, callback: Callback<string>): void;
338 lindex(key: KeyType, index: number): Promise<string>;
339
340 lset(key: KeyType, index: number, value: ValueType, callback: Callback<Ok>): void;
341 lset(key: KeyType, index: number, value: ValueType): Promise<Ok>;
342
343 lrange(key: KeyType, start: number, stop: number, callback: Callback<string[]>): void;
344 lrange(key: KeyType, start: number, stop: number): Promise<string[]>;
345
346 lrangeBuffer(key: KeyType, start: number, stop: number, callback: Callback<Buffer[]>): void;
347 lrangeBuffer(key: KeyType, start: number, stop: number): Promise<Buffer[]>;
348
349 ltrim(key: KeyType, start: number, stop: number, callback: Callback<Ok>): void;
350 ltrim(key: KeyType, start: number, stop: number): Promise<Ok>;
351
352 lrem(key: KeyType, count: number, value: ValueType, callback: Callback<number>): void;
353 lrem(key: KeyType, count: number, value: ValueType): Promise<number>;
354
355 rpoplpush(source: string, destination: string, callback: Callback<string>): void;
356 rpoplpush(source: string, destination: string): Promise<string>;
357
358 rpoplpushBuffer(source: string, destination: string, callback: Callback<Buffer>): void;
359 rpoplpushBuffer(source: string, destination: string): Promise<Buffer>;
360
361 sadd: OverloadedKeyCommand<ValueType, number>;
362
363 srem: OverloadedKeyCommand<ValueType, number>;
364
365 smove(source: string, destination: string, member: string, callback: Callback<BooleanResponse>): void;
366 smove(source: string, destination: string, member: string): Promise<BooleanResponse>;
367
368 sismember(key: KeyType, member: string, callback: Callback<BooleanResponse>): void;
369 sismember(key: KeyType, member: string): Promise<BooleanResponse>;
370
371 scard(key: KeyType, callback: Callback<number>): void;
372 scard(key: KeyType): Promise<number>;
373
374 spop(key: KeyType, callback: Callback<string | null>): void;
375 spop(key: KeyType): Promise<string | null>;
376 spop(key: KeyType, count: number, callback: Callback<string[]>): void;
377 spop(key: KeyType, count: number): Promise<string[]>;
378
379 srandmember(key: KeyType, callback: Callback<string | null>): void;
380 srandmember(key: KeyType): Promise<string | null>;
381 srandmember(key: KeyType, count: number, callback: Callback<string[]>): void;
382 srandmember(key: KeyType, count: number): Promise<string[]>;
383
384 sinter: OverloadedListCommand<KeyType, string[]>;
385
386 sinterstore: OverloadedKeyCommand<KeyType, number>;
387
388 sunion: OverloadedListCommand<KeyType, string[]>;
389
390 sunionstore: OverloadedKeyCommand<KeyType, number>;
391
392 sdiff: OverloadedListCommand<KeyType, string[]>;
393
394 sdiffstore: OverloadedKeyCommand<KeyType, number>;
395
396 smembers(key: KeyType, callback: Callback<string[]>): void;
397 smembers(key: KeyType): Promise<string[]>;
398
399 zadd: OverloadedKeyCommand<KeyType | number, number | string>;
400
401 zaddBuffer(key: KeyType, score1: number, member1: Buffer, callback: Callback<string | number>): void;
402 zaddBuffer(key: KeyType, score1: number, member1: Buffer): Promise<string | number>;
403
404 zincrby(key: KeyType, increment: number, member: string, callback: Callback<string>): void;
405 zincrby(key: KeyType, increment: number, member: string): Promise<string>;
406
407 zpopmin(key: KeyType, callback: Callback<string[]>): void;
408 zpopmin(key: KeyType, count: number, callback: Callback<string[]>): void;
409 zpopmin(key: KeyType, count?: number): Promise<string[]>;
410
411 zpopmax(key: KeyType, callback: Callback<string[]>): void;
412 zpopmax(key: KeyType, count: number, callback: Callback<string[]>): void;
413 zpopmax(key: KeyType, count?: number): Promise<string[]>;
414
415 bzpopmin: OverloadedBlockingListCommand<KeyType, [string, string, string]>;
416
417 bzpopmax: OverloadedBlockingListCommand<KeyType, [string, string, string]>;
418
419 zrem: OverloadedKeyCommand<ValueType, number>;
420
421 zremrangebyscore(key: KeyType, min: number | string, max: number | string, callback: Callback<number>): void;
422 zremrangebyscore(key: KeyType, min: number | string, max: number | string): Promise<number>;
423
424 zremrangebyrank(key: KeyType, start: number, stop: number, callback: Callback<number>): void;
425 zremrangebyrank(key: KeyType, start: number, stop: number): Promise<number>;
426
427 zremrangebylex(
428 key: KeyType,
429 min: string,
430 max: string,
431 ): Promise<number>;
432 zremrangebylex(
433 key: KeyType,
434 min: string,
435 max: string,
436 callback: Callback<number>
437 ): void;
438
439 zunionstore: OverloadedKeyCommand<KeyType | number, number>;
440
441 zinterstore: OverloadedKeyCommand<KeyType | number, number>;
442
443 zrange(key: KeyType, start: number, stop: number, callback: Callback<string[]>): void;
444 zrange(key: KeyType, start: number, stop: number, withScores: 'WITHSCORES', callback: Callback<string[]>): void;
445 zrange(key: KeyType, start: number, stop: number, withScores?: 'WITHSCORES'): Promise<string[]>;
446
447 zrangeBuffer(key: KeyType, start: number, stop: number, callback: Callback<Buffer[]>): void;
448 zrangeBuffer(key: KeyType, start: number, stop: number, withScores: 'WITHSCORES', callback: Callback<Buffer[]>): void;
449 zrangeBuffer(key: KeyType, start: number, stop: number, withScores?: 'WITHSCORES'): Promise<Buffer[]>;
450
451 zrevrange(key: KeyType, start: number, stop: number, callback: Callback<string[]>): void;
452 zrevrange(
453 key: KeyType,
454 start: number,
455 stop: number,
456 withScores: 'WITHSCORES',
457 callback: Callback<string[]>,
458 ): void;
459 zrevrange(key: KeyType, start: number, stop: number, withScores?: 'WITHSCORES'): Promise<string[]>;
460
461 zrevrangeBuffer(key: KeyType, start: number, stop: number, callback: Callback<Buffer[]>): void;
462 zrevrangeBuffer(
463 key: KeyType,
464 start: number,
465 stop: number,
466 withScores: 'WITHSCORES',
467 callback: Callback<Buffer[]>,
468 ): void;
469 zrevrangeBuffer(key: KeyType, start: number, stop: number, withScores?: 'WITHSCORES'): Promise<Buffer[]>;
470
471 zrangebyscore(
472 key: KeyType,
473 min: number | string,
474 max: number | string,
475 withScores?: 'WITHSCORES',
476 ): Promise<string[]>;
477 zrangebyscore(
478 key: KeyType,
479 min: number | string,
480 max: number | string,
481 withScores: 'WITHSCORES',
482 limit: 'LIMIT',
483 offset: number,
484 count: number,
485 ): Promise<string[]>;
486 zrangebyscore(
487 key: KeyType,
488 min: number | string,
489 max: number | string,
490 limit: 'LIMIT',
491 offset: number,
492 count: number,
493 ): Promise<string[]>;
494 zrangebyscore(key: KeyType, min: number | string, max: number | string, callback: Callback<string[]>): void;
495 zrangebyscore(
496 key: KeyType,
497 min: number | string,
498 max: number | string,
499 withScores: 'WITHSCORES',
500 callback: Callback<string[]>,
501 ): void;
502 zrangebyscore(
503 key: KeyType,
504 min: number | string,
505 max: number | string,
506 withScores: 'WITHSCORES',
507 limit: 'LIMIT',
508 offset: number,
509 count: number,
510 callback: Callback<string[]>,
511 ): void;
512 zrangebyscore(
513 key: KeyType,
514 min: number | string,
515 max: number | string,
516 limit: 'LIMIT',
517 offset: number,
518 count: number,
519 callback: Callback<string[]>,
520 ): void;
521
522 zrangebyscoreBuffer(
523 key: KeyType,
524 min: number | string,
525 max: number | string,
526 withScores?: 'WITHSCORES',
527 ): Promise<Buffer[]>;
528 zrangebyscoreBuffer(
529 key: KeyType,
530 min: number | string,
531 max: number | string,
532 withScores: 'WITHSCORES',
533 limit: 'LIMIT',
534 offset: number,
535 count: number,
536 ): Promise<Buffer[]>;
537 zrangebyscoreBuffer(
538 key: KeyType,
539 min: number | string,
540 max: number | string,
541 limit: 'LIMIT',
542 offset: number,
543 count: number,
544 ): Promise<Buffer[]>;
545 zrangebyscoreBuffer(key: KeyType, min: number | string, max: number | string, callback: Callback<Buffer[]>): void;
546 zrangebyscoreBuffer(
547 key: KeyType,
548 min: number | string,
549 max: number | string,
550 withScores: 'WITHSCORES',
551 callback: Callback<Buffer[]>,
552 ): void;
553 zrangebyscoreBuffer(
554 key: KeyType,
555 min: number | string,
556 max: number | string,
557 withScores: 'WITHSCORES',
558 limit: 'LIMIT',
559 offset: number,
560 count: number,
561 callback: Callback<Buffer[]>,
562 ): void;
563 zrangebyscoreBuffer(
564 key: KeyType,
565 min: number | string,
566 max: number | string,
567 limit: 'LIMIT',
568 offset: number,
569 count: number,
570 callback: Callback<Buffer[]>,
571 ): void;
572
573 zrevrangebyscore(
574 key: KeyType,
575 max: number | string,
576 min: number | string,
577 withScores?: 'WITHSCORES',
578 ): Promise<string[]>;
579 zrevrangebyscore(
580 key: KeyType,
581 max: number | string,
582 min: number | string,
583 withScores: 'WITHSCORES',
584 limit: 'LIMIT',
585 offset: number,
586 count: number,
587 ): Promise<string[]>;
588 zrevrangebyscore(
589 key: KeyType,
590 max: number | string,
591 min: number | string,
592 limit: 'LIMIT',
593 offset: number,
594 count: number,
595 ): Promise<string[]>;
596 zrevrangebyscore(key: KeyType, max: number | string, min: number | string, callback: Callback<string[]>): void;
597 zrevrangebyscore(
598 key: KeyType,
599 max: number | string,
600 min: number | string,
601 withScores: 'WITHSCORES',
602 callback: Callback<string[]>,
603 ): void;
604 zrevrangebyscore(
605 key: KeyType,
606 max: number | string,
607 min: number | string,
608 withScores: 'WITHSCORES',
609 limit: 'LIMIT',
610 offset: number,
611 count: number,
612 callback: Callback<string[]>,
613 ): void;
614 zrevrangebyscore(
615 key: KeyType,
616 max: number | string,
617 min: number | string,
618 limit: 'LIMIT',
619 offset: number,
620 count: number,
621 callback: Callback<string[]>,
622 ): void;
623
624 zrevrangebyscoreBuffer(
625 key: KeyType,
626 max: number | string,
627 min: number | string,
628 withScores?: 'WITHSCORES',
629 ): Promise<Buffer[]>;
630 zrevrangebyscoreBuffer(
631 key: KeyType,
632 max: number | string,
633 min: number | string,
634 withScores: 'WITHSCORES',
635 limit: 'LIMIT',
636 offset: number,
637 count: number,
638 ): Promise<Buffer[]>;
639 zrevrangebyscoreBuffer(
640 key: KeyType,
641 max: number | string,
642 min: number | string,
643 limit: 'LIMIT',
644 offset: number,
645 count: number,
646 ): Promise<Buffer[]>;
647 zrevrangebyscoreBuffer(key: KeyType, max: number | string, min: number | string, callback: Callback<Buffer[]>): void;
648 zrevrangebyscoreBuffer(
649 key: KeyType,
650 max: number | string,
651 min: number | string,
652 withScores: 'WITHSCORES',
653 callback: Callback<Buffer[]>,
654 ): void;
655 zrevrangebyscoreBuffer(
656 key: KeyType,
657 max: number | string,
658 min: number | string,
659 withScores: 'WITHSCORES',
660 limit: 'LIMIT',
661 offset: number,
662 count: number,
663 callback: Callback<Buffer[]>,
664 ): void;
665 zrevrangebyscoreBuffer(
666 key: KeyType,
667 max: number | string,
668 min: number | string,
669 limit: 'LIMIT',
670 offset: number,
671 count: number,
672 callback: Callback<Buffer[]>,
673 ): void;
674
675 zrangebylex(
676 key: KeyType,
677 min: string,
678 max: string,
679 ): Promise<string[]>;
680 zrangebylex(
681 key: KeyType,
682 min: string,
683 max: string,
684 limit: 'LIMIT',
685 offset: number,
686 count: number,
687 ): Promise<string[]>;
688 zrangebylex(
689 key: KeyType,
690 min: string,
691 max: string,
692 callback: Callback<string[]>,
693 ): void;
694 zrangebylex(
695 key: KeyType,
696 min: string,
697 max: string,
698 limit: 'LIMIT',
699 offset: number,
700 count: number,
701 callback: Callback<string[]>,
702 ): void;
703
704 zrangebylexBuffer(
705 key: KeyType,
706 min: string,
707 max: string,
708 ): Promise<Buffer[]>;
709 zrangebylexBuffer(
710 key: KeyType,
711 min: string,
712 max: string,
713 limit: 'LIMIT',
714 offset: number,
715 count: number,
716 ): Promise<Buffer[]>;
717 zrangebylexBuffer(
718 key: KeyType,
719 min: string,
720 max: string,
721 callback: Callback<Buffer[]>,
722 ): void;
723 zrangebylexBuffer(
724 key: KeyType,
725 min: string,
726 max: string,
727 limit: 'LIMIT',
728 offset: number,
729 count: number,
730 callback: Callback<Buffer[]>,
731 ): void;
732
733 zrevrangebylex(
734 key: KeyType,
735 min: string,
736 max: string,
737 ): Promise<string[]>;
738 zrevrangebylex(
739 key: KeyType,
740 min: string,
741 max: string,
742 limit: 'LIMIT',
743 offset: number,
744 count: number,
745 ): Promise<string[]>;
746 zrevrangebylex(
747 key: KeyType,
748 min: string,
749 max: string,
750 callback: Callback<string[]>,
751 ): void;
752 zrevrangebylex(
753 key: KeyType,
754 min: string,
755 max: string,
756 limit: 'LIMIT',
757 offset: number,
758 count: number,
759 callback: Callback<string[]>,
760 ): void;
761
762 zrevrangebylexBuffer(
763 key: KeyType,
764 min: string,
765 max: string,
766 ): Promise<Buffer[]>;
767 zrevrangebylexBuffer(
768 key: KeyType,
769 min: string,
770 max: string,
771 limit: 'LIMIT',
772 offset: number,
773 count: number,
774 ): Promise<Buffer[]>;
775 zrevrangebylexBuffer(
776 key: KeyType,
777 min: string,
778 max: string,
779 callback: Callback<Buffer[]>,
780 ): void;
781 zrevrangebylexBuffer(
782 key: KeyType,
783 min: string,
784 max: string,
785 limit: 'LIMIT',
786 offset: number,
787 count: number,
788 callback: Callback<Buffer[]>,
789 ): void;
790
791 zcount(key: KeyType, min: number | string, max: number | string, callback: Callback<number>): void;
792 zcount(key: KeyType, min: number | string, max: number | string): Promise<number>;
793
794 zcard(key: KeyType, callback: Callback<number>): void;
795 zcard(key: KeyType): Promise<number>;
796
797 zscore(key: KeyType, member: string, callback: Callback<string>): void;
798 zscore(key: KeyType, member: string): Promise<string>;
799
800 zrank(key: KeyType, member: string, callback: Callback<number | null>): void;
801 zrank(key: KeyType, member: string): Promise<number | null>;
802
803 zrevrank(key: KeyType, member: string, callback: Callback<number | null>): void;
804 zrevrank(key: KeyType, member: string): Promise<number | null>;
805
806 hset: OverloadedKeyedHashCommand<ValueType, Ok>;
807
808 hsetBuffer(key: KeyType, field: string, value: ValueType, callback: Callback<BooleanResponse>): void;
809 hsetBuffer(key: KeyType, field: string, value: ValueType): Promise<Buffer>;
810
811 hsetnx(key: KeyType, field: string, value: ValueType, callback: Callback<BooleanResponse>): void;
812 hsetnx(key: KeyType, field: string, value: ValueType): Promise<BooleanResponse>;
813
814 hget(key: KeyType, field: string, callback: Callback<string | null>): void;
815 hget(key: KeyType, field: string): Promise<string | null>;
816 hgetBuffer(key: KeyType, field: string, callback: Callback<Buffer>): void;
817 hgetBuffer(key: KeyType, field: string): Promise<Buffer>;
818
819 hmset: OverloadedKeyedHashCommand<ValueType, Ok>;
820
821 hmget: OverloadedKeyCommand<KeyType, Array<string | null>>;
822
823 hstrlen(key: KeyType, field: string, callback: Callback<number>): void;
824 hstrlen(key: KeyType, field: string): Promise<number>;
825
826 hincrby(key: KeyType, field: string, increment: number, callback: Callback<number>): void;
827 hincrby(key: KeyType, field: string, increment: number): Promise<number>;
828
829 hincrbyfloat(key: KeyType, field: string, increment: number, callback: Callback<number>): void;
830 hincrbyfloat(key: KeyType, field: string, increment: number): Promise<number>;
831
832 hdel: OverloadedKeyCommand<KeyType, number>;
833
834 hlen(key: KeyType, callback: Callback<number>): void;
835 hlen(key: KeyType): Promise<number>;
836
837 hkeys(key: KeyType, callback: Callback<string[]>): void;
838 hkeys(key: KeyType): Promise<string[]>;
839
840 hvals(key: KeyType, callback: Callback<string[]>): void;
841 hvals(key: KeyType): Promise<string[]>;
842
843 hgetall(key: KeyType, callback: Callback<Record<string, string>>): void;
844 hgetall(key: KeyType): Promise<Record<string, string>>;
845
846 hexists(key: KeyType, field: string, callback: Callback<BooleanResponse>): void;
847 hexists(key: KeyType, field: string): Promise<BooleanResponse>;
848
849 geoadd(key: KeyType, longitude: number, latitude: number, member: string, callback: Callback<number>): void;
850 geoadd(key: KeyType, longitude: number, latitude: number, member: string): Promise<number>;
851
852 geodist(key: KeyType, member1: string, member2: string, unit: 'm'|'km'|'ft'|'mi', callback: Callback<string | null>): void;
853 geodist(key: KeyType, member1: string, member2: string, unit: 'm'|'km'|'ft'|'mi'): Promise<string | null>;
854
855 geohash: OverloadedKeyCommand<string, string[]>;
856
857 geopos: OverloadedKeyCommand<string, string[]>;
858
859 georadius(
860 key: KeyType,
861 longitude: number,
862 latitude: number,
863 radius: number,
864 unit: 'm'|'km'|'ft'|'mi',
865 callback: Callback<string[]>,
866 ): void;
867 georadius(
868 key: KeyType,
869 longitude: number,
870 latitude: number,
871 radius: number,
872 unit: 'm'|'km'|'ft'|'mi',
873 sort?: 'ASC' | 'DESC'
874 ): Promise<string[]>;
875 georadius(
876 key: KeyType,
877 longitude: number,
878 latitude: number,
879 radius: number,
880 unit: 'm'|'km'|'ft'|'mi',
881 count: 'COUNT',
882 countValue: number,
883 sort?: 'ASC' | 'DESC'
884 ): Promise<string[]>;
885
886 georadiusbymember(key: KeyType, member: string, radius: number, unit: 'm'|'km'|'ft'|'mi', callback: Callback<string[]>): void;
887 georadiusbymember(key: KeyType, member: string, radius: number, unit: 'm'|'km'|'ft'|'mi', count: 'COUNT', countValue: number, callback: Callback<string[]>): void;
888 georadiusbymember(key: KeyType, member: string, radius: number, unit: 'm'|'km'|'ft'|'mi'): Promise<string[]>;
889 georadiusbymember(key: KeyType, member: string, radius: number, unit: 'm'|'km'|'ft'|'mi', count: 'COUNT', countValue: number): Promise<string[]>;
890
891 incrby(key: KeyType, increment: number, callback: Callback<number>): void;
892 incrby(key: KeyType, increment: number): Promise<number>;
893
894 incrbyfloat(key: KeyType, increment: number, callback: Callback<number>): void;
895 incrbyfloat(key: KeyType, increment: number): Promise<number>;
896
897 decrby(key: KeyType, decrement: number, callback: Callback<number>): void;
898 decrby(key: KeyType, decrement: number): Promise<number>;
899
900 getset(key: KeyType, value: ValueType, callback: Callback<string | null>): void;
901 getset(key: KeyType, value: ValueType): Promise<string | null>;
902
903 mset: OverloadedHashCommand<ValueType, Ok>;
904 msetnx: OverloadedHashCommand<ValueType, BooleanResponse>;
905
906 memory(argument: 'USAGE', key: KeyType, callback?: Callback<number>): Promise<number>;
907
908 randomkey(callback: Callback<string>): void;
909 randomkey(): Promise<string>;
910
911 select(index: number, callback: Callback<Ok>): void;
912 select(index: number): Promise<Ok>;
913
914 move(key: KeyType, db: string, callback: Callback<BooleanResponse>): void;
915 move(key: KeyType, db: string): Promise<BooleanResponse>;
916
917 rename(key: KeyType, newkey: KeyType, callback: Callback<Ok>): void;
918 rename(key: KeyType, newkey: KeyType): Promise<Ok>;
919
920 renamenx(key: KeyType, newkey: KeyType, callback: Callback<BooleanResponse>): void;
921 renamenx(key: KeyType, newkey: KeyType): Promise<BooleanResponse>;
922
923 expire(key: KeyType, seconds: number, callback: Callback<BooleanResponse>): void;
924 expire(key: KeyType, seconds: number): Promise<BooleanResponse>;
925
926 pexpire(key: KeyType, milliseconds: number, callback: Callback<BooleanResponse>): void;
927 pexpire(key: KeyType, milliseconds: number): Promise<BooleanResponse>;
928
929 expireat(key: KeyType, timestamp: number, callback: Callback<BooleanResponse>): void;
930 expireat(key: KeyType, timestamp: number): Promise<BooleanResponse>;
931
932 pexpireat(key: KeyType, millisecondsTimestamp: number, callback: Callback<BooleanResponse>): void;
933 pexpireat(key: KeyType, millisecondsTimestamp: number): Promise<BooleanResponse>;
934
935 keys(pattern: string, callback: Callback<string[]>): void;
936 keys(pattern: string): Promise<string[]>;
937
938 dbsize(callback: Callback<number>): void;
939 dbsize(): Promise<number>;
940
941 auth(username: string, password: string, callback: Callback<string>): void;
942 auth(password: string, callback: Callback<string>): void;
943 // tslint:disable-next-line unified-signatures
944 auth(username: string, password: string): Promise<string>;
945 auth(password: string): Promise<string>;
946
947 ping(callback: Callback<string>): void;
948 ping(message: string, callback: Callback<string>): void;
949 ping(message?: string): Promise<string>;
950
951 echo(message: string, callback: Callback<string>): void;
952 echo(message: string): Promise<string>;
953
954 save(callback: Callback<string>): void;
955 save(): Promise<string>;
956
957 bgsave(callback: Callback<string>): void;
958 bgsave(): Promise<string>;
959
960 bgrewriteaof(callback: Callback<string>): void;
961 bgrewriteaof(): Promise<string>;
962
963 shutdown(save: 'SAVE' | 'NOSAVE', callback: Callback<never>): void;
964 shutdown(save: 'SAVE' | 'NOSAVE'): Promise<never>;
965
966 lastsave(callback: Callback<number>): void;
967 lastsave(): Promise<number>;
968
969 type(key: KeyType, callback: Callback<string>): void;
970 type(key: KeyType): Promise<string>;
971
972 multi(commands?: string[][], options?: MultiOptions): Pipeline;
973 multi(options: { pipeline: false }): Promise<Ok>;
974
975 exec(callback: Callback<Array<[Error | null, string]>>): void;
976 exec(): Promise<Array<[Error | null, string]>>;
977
978 discard(callback: Callback<Ok>): void;
979 discard(): Promise<Ok>;
980
981 sync(callback: Callback<any>): void;
982 sync(): Promise<any>;
983
984 flushdb(callback: Callback<Ok>): void;
985 flushdb(): Promise<Ok>;
986
987 flushall(callback: Callback<Ok>): void;
988 flushall(): Promise<Ok>;
989
990 sort: OverloadedListCommand<KeyType | number, string[] | number>;
991
992 info(callback: Callback<string>): void;
993 info(section: string, callback: Callback<string>): void;
994 info(section?: string): Promise<string>;
995
996 time(callback: Callback<[string, string]>): void;
997 time(): Promise<[string, string]>;
998
999 monitor(callback: Callback<EventEmitter>): void;
1000 monitor(): Promise<EventEmitter>;
1001
1002 ttl(key: KeyType, callback: Callback<number>): void;
1003 ttl(key: KeyType): Promise<number>;
1004
1005 pttl(key: KeyType, callback: Callback<number>): void;
1006 pttl(key: KeyType): Promise<number>;
1007
1008 persist(key: KeyType, callback: Callback<BooleanResponse>): void;
1009 persist(key: KeyType): Promise<BooleanResponse>;
1010
1011 slaveof(host: string, port: number, callback: Callback<string>): void;
1012 slaveof(host: string, port: number): Promise<string>;
1013
1014 debug: OverloadedSubCommand<ValueType, any>;
1015
1016 config(op: 'GET', cfg: string): Promise<string[]>;
1017 config(op: 'GET', cfg: string, callback: Callback<string[]>): void;
1018 config(op: 'REWRITE' | 'RESETSTAT'): Promise<Ok>;
1019 config(op: 'REWRITE' | 'RESETSTAT', callback: Callback<Ok>): void;
1020 config(op: 'SET', key: string, value: ValueType): Promise<Ok>;
1021 config(op: 'SET', key: string, value: ValueType, callback: Callback<Ok>): void;
1022
1023 subscribe: OverloadedListCommand<string, number>;
1024
1025 unsubscribe: OverloadedCommand<string, number>;
1026
1027 psubscribe: OverloadedListCommand<string, number>;
1028
1029 punsubscribe: OverloadedCommand<string, number>;
1030
1031 publish(channel: string, message: string, callback: Callback<number>): void;
1032 publish(channel: string, message: string): Promise<number>;
1033
1034 publishBuffer(channel: string, message: Buffer): Promise<number>;
1035
1036 watch: OverloadedListCommand<KeyType, Ok>;
1037
1038 unwatch(callback: Callback<string>): void;
1039 unwatch(): Promise<string>;
1040
1041 cluster: OverloadedSubCommand<ValueType, any>;
1042
1043 restore: OverloadedListCommand<ValueType, Ok>;
1044
1045 migrate: OverloadedListCommand<ValueType, Ok | 'NOKEY'>;
1046
1047 dump(key: KeyType, callback: Callback<string>): void;
1048 dump(key: KeyType): Promise<string>;
1049
1050 object: OverloadedListCommand<ValueType, any>;
1051
1052 client: OverloadedSubCommand<ValueType, any>;
1053
1054 eval: OverloadedEvalCommand<ValueType, any>;
1055
1056 evalsha: OverloadedEvalCommand<ValueType, any>;
1057
1058 script: OverloadedSubCommand<ValueType, any>;
1059
1060 quit(callback: Callback<Ok>): void;
1061 quit(): Promise<Ok>;
1062
1063 scan(cursor: number | string, matchOption: 'match' | 'MATCH', pattern: string): Promise<[string, string[]]>;
1064 scan(
1065 cursor: number | string,
1066 matchOption: 'match' | 'MATCH',
1067 pattern: string,
1068 callback: Callback<[string, string[]]>,
1069 ): void;
1070 scan(cursor: number | string, countOption: 'count' | 'COUNT', count: number): Promise<[string, string[]]>;
1071 scan(
1072 cursor: number | string,
1073 countOption: 'count' | 'COUNT',
1074 count: number,
1075 callback: Callback<[string, string[]]>,
1076 ): void;
1077
1078 scan(
1079 cursor: number | string,
1080 matchOption: 'match' | 'MATCH',
1081 pattern: string,
1082 countOption: 'count' | 'COUNT',
1083 count: number,
1084 ): Promise<[string, string[]]>;
1085 scan(
1086 cursor: number | string,
1087 matchOption: 'match' | 'MATCH',
1088 pattern: string,
1089 countOption: 'count' | 'COUNT',
1090 count: number,
1091 callback: Callback<[string, string[]]>,
1092 ): void;
1093 scan(
1094 cursor: number | string,
1095 countOption: 'count' | 'COUNT',
1096 count: number,
1097 matchOption: 'match' | 'MATCH',
1098 pattern: string,
1099 ): Promise<[string, string[]]>;
1100 scan(
1101 cursor: number | string,
1102 countOption: 'count' | 'COUNT',
1103 count: number,
1104 matchOption: 'match' | 'MATCH',
1105 pattern: string,
1106 callback: Callback<[string, string[]]>,
1107 ): void;
1108
1109 sscan: OverloadedKeyCommand<ValueType, [string, string[]]>;
1110
1111 hscan: OverloadedKeyCommand<ValueType, [string, string[]]>;
1112
1113 zscan: OverloadedKeyCommand<ValueType, [string, string[]]>;
1114
1115 pfmerge: OverloadedKeyCommand<KeyType, Ok>;
1116
1117 pfadd: OverloadedKeyCommand<string, number>;
1118
1119 pfcount: OverloadedListCommand<KeyType, number>;
1120
1121 pipeline(commands?: string[][]): Pipeline;
1122
1123 scanStream(options?: ScanStreamOption): Readable;
1124 sscanStream(key: KeyType, options?: ScanStreamOption): Readable;
1125 hscanStream(key: KeyType, options?: ScanStreamOption): Readable;
1126 zscanStream(key: KeyType, options?: ScanStreamOption): Readable;
1127
1128 xack: OverloadedKeyCommand<ValueType, number>;
1129
1130 xadd: OverloadedKeyCommand<ValueType, string>;
1131
1132 xclaim: OverloadedKeyCommand<ValueType, Array<[string, string[]]>>;
1133
1134 xdel: OverloadedKeyCommand<string, number>;
1135
1136 xgroup: OverloadedSubCommand<ValueType, Ok>;
1137
1138 xinfo: OverloadedSubCommand<ValueType, any>;
1139
1140 xlen(key: KeyType): Promise<number>;
1141 xlen(key: KeyType, callback: Callback<number>): void;
1142
1143 xpending: OverloadedKeyCommand<ValueType, any>;
1144
1145 xrange: OverloadedKeyCommand<ValueType, Array<[string, string[]]>>;
1146
1147 xread: OverloadedListCommand<ValueType, Array<[string, string[]]>>;
1148
1149 xreadgroup: OverloadedKeyCommand<ValueType, Array<[string, string[]]>>;
1150
1151 xrevrange: OverloadedKeyCommand<ValueType, Array<[string, string[]]>>;
1152
1153 xtrim: OverloadedKeyCommand<ValueType, number>;
1154 }
1155
1156 interface Redis extends EventEmitter, Commander, Commands {
1157 Promise: typeof Promise;
1158 readonly options: RedisOptions;
1159 readonly status: string;
1160 connect(callback?: () => void): Promise<void>;
1161 disconnect(): void;
1162 duplicate(): Redis;
1163
1164 send_command(command: string, ...args: ValueType[]): Promise<any>;
1165 }
1166
1167 interface Pipeline {
1168 readonly redis: Redis | Cluster;
1169 readonly isCluster: boolean;
1170 readonly options: RedisOptions | ClusterOptions;
1171 readonly length: number;
1172
1173 bitcount(key: KeyType, callback?: Callback<number>): Pipeline;
1174 bitcount(key: KeyType, start: number, end: number, callback?: Callback<number>): Pipeline;
1175
1176 get(key: KeyType, callback?: Callback<string>): Pipeline;
1177 getBuffer(key: KeyType, callback?: Callback<Buffer>): Pipeline;
1178
1179 set(key: KeyType, value: ValueType, callback?: Callback<string>): Pipeline;
1180 set(key: KeyType, value: ValueType, setMode: string, callback?: Callback<string>): Pipeline;
1181 set(key: KeyType, value: ValueType, expiryMode: string, time: number, callback?: Callback<string>): Pipeline;
1182 set(
1183 key: KeyType,
1184 value: ValueType,
1185 expiryMode: string,
1186 time: number,
1187 setMode: string,
1188 callback?: Callback<string>,
1189 ): Pipeline;
1190
1191 setBuffer(key: KeyType, value: ValueType, callback?: Callback<Buffer>): Pipeline;
1192 setBuffer(key: KeyType, value: ValueType, setMode: string, callback?: Callback<Buffer>): Pipeline;
1193 setBuffer(
1194 key: KeyType,
1195 value: ValueType,
1196 expiryMode: string,
1197 time: number,
1198 callback?: Callback<Buffer>,
1199 ): Pipeline;
1200 setBuffer(
1201 key: KeyType,
1202 value: ValueType,
1203 expiryMode: string,
1204 time: number,
1205 setMode: string,
1206 callback?: Callback<Buffer>,
1207 ): Pipeline;
1208
1209 setnx(key: KeyType, value: ValueType, callback?: Callback<BooleanResponse>): Pipeline;
1210
1211 setex(key: KeyType, seconds: number, value: ValueType, callback?: Callback<Ok>): Pipeline;
1212
1213 psetex(key: KeyType, milliseconds: number, value: ValueType, callback?: Callback<Ok>): Pipeline;
1214
1215 append(key: KeyType, value: ValueType, callback?: Callback<number>): Pipeline;
1216
1217 strlen(key: KeyType, callback?: Callback<number>): Pipeline;
1218
1219 del(...keys: KeyType[]): Pipeline;
1220
1221 unlink(...keys: KeyType[]): Pipeline;
1222
1223 exists(...keys: KeyType[]): Pipeline;
1224
1225 setbit(key: KeyType, offset: number, value: ValueType, callback?: Callback<number>): Pipeline;
1226
1227 getbit(key: KeyType, offset: number, callback?: Callback<number>): Pipeline;
1228
1229 setrange(key: KeyType, offset: number, value: ValueType, callback?: Callback<number>): Pipeline;
1230
1231 getrange(key: KeyType, start: number, end: number, callback?: Callback<string>): Pipeline;
1232
1233 getrangeBuffer(key: KeyType, start: number, end: number, callback?: Callback<Buffer>): Pipeline;
1234
1235 substr(key: KeyType, start: number, end: number, callback?: Callback<string>): Pipeline;
1236
1237 incr(key: KeyType, callback?: Callback<number>): Pipeline;
1238
1239 decr(key: KeyType, callback?: Callback<number>): Pipeline;
1240
1241 mget(...keys: KeyType[]): Pipeline;
1242
1243 rpush(key: KeyType, ...values: ValueType[]): Pipeline;
1244
1245 rpushBuffer(key: string, ...values: Buffer[]): Pipeline;
1246
1247 lpush(key: KeyType, ...values: ValueType[]): Pipeline;
1248
1249 rpushx(key: KeyType, value: ValueType, callback?: Callback<number>): Pipeline;
1250
1251 lpushx(key: KeyType, value: ValueType, callback?: Callback<number>): Pipeline;
1252
1253 linsert(
1254 key: KeyType,
1255 direction: 'BEFORE' | 'AFTER',
1256 pivot: string,
1257 value: ValueType,
1258 callback?: Callback<number>,
1259 ): Pipeline;
1260
1261 rpop(key: KeyType, callback?: Callback<string>): Pipeline;
1262
1263 lpop(key: KeyType, callback?: Callback<string>): Pipeline;
1264
1265 lpopBuffer(key: KeyType, callback?: Callback<Buffer>): Pipeline;
1266
1267 brpop(...keys: KeyType[]): Pipeline;
1268
1269 blpop(...keys: KeyType[]): Pipeline;
1270
1271 brpoplpush(source: string, destination: string, timeout: number, callback?: Callback<string>): Pipeline;
1272
1273 llen(key: KeyType, callback?: Callback<number>): Pipeline;
1274
1275 lindex(key: KeyType, index: number, callback?: Callback<string>): Pipeline;
1276
1277 lset(key: KeyType, index: number, value: ValueType, callback?: Callback<Ok>): Pipeline;
1278
1279 lrange(key: KeyType, start: number, stop: number, callback?: Callback<string[]>): Pipeline;
1280
1281 lrangeBuffer(key: KeyType, start: number, stop: number, callback?: Callback<Buffer[]>): Pipeline;
1282
1283 ltrim(key: KeyType, start: number, stop: number, callback?: Callback<Ok>): Pipeline;
1284
1285 lrem(key: KeyType, count: number, value: ValueType, callback?: Callback<number>): Pipeline;
1286
1287 rpoplpush(source: string, destination: string, callback?: Callback<string>): Pipeline;
1288
1289 sadd(key: KeyType, ...members: ValueType[]): Pipeline;
1290
1291 srem(key: KeyType, ...members: ValueType[]): Pipeline;
1292
1293 smove(source: string, destination: string, member: string, callback?: Callback<string>): Pipeline;
1294
1295 sismember(key: KeyType, member: string, callback?: Callback<BooleanResponse>): Pipeline;
1296
1297 scard(key: KeyType, callback?: Callback<number>): Pipeline;
1298
1299 spop(key: KeyType, callback?: Callback<string | null>): Pipeline;
1300 spop(key: KeyType, count: number, callback?: Callback<string[]>): Pipeline;
1301
1302 srandmember(key: KeyType, callback?: Callback<string | null>): Pipeline;
1303 srandmember(key: KeyType, count: number, callback?: Callback<string[]>): Pipeline;
1304
1305 sinter(...keys: KeyType[]): Pipeline;
1306
1307 sinterstore(destination: string, ...keys: KeyType[]): Pipeline;
1308
1309 sunion(...keys: KeyType[]): Pipeline;
1310
1311 sunionstore(destination: string, ...keys: KeyType[]): Pipeline;
1312
1313 sdiff(...keys: KeyType[]): Pipeline;
1314
1315 sdiffstore(destination: string, ...keys: KeyType[]): Pipeline;
1316
1317 smembers(key: KeyType, callback?: Callback<string[]>): Pipeline;
1318
1319 zadd(key: KeyType, ...args: string[]): Pipeline;
1320
1321 zincrby(key: KeyType, increment: number, member: string, callback?: Callback<string>): Pipeline;
1322
1323 zpopmin(key: KeyType, count: number, callback?: Callback<string[]>): Pipeline;
1324
1325 zpopmax(key: KeyType, count: number, callback?: Callback<string[]>): Pipeline;
1326
1327 bzpopmin(...args: Array<string | number | Callback<[string, string, string]>>): Pipeline;
1328
1329 bzpopmax(...args: Array<string | number | Callback<[string, string, string]>>): Pipeline;
1330
1331 zrem(key: KeyType, ...members: ValueType[]): Pipeline;
1332
1333 zremrangebyscore(
1334 key: KeyType,
1335 min: number | string,
1336 max: number | string,
1337 callback?: Callback<number>,
1338 ): Pipeline;
1339
1340 zremrangebyrank(key: KeyType, start: number, stop: number, callback?: Callback<number>): Pipeline;
1341
1342 zremrangebylex(
1343 key: KeyType,
1344 min: string,
1345 max: string,
1346 callback?: Callback<number>,
1347 ): Pipeline;
1348
1349 zunionstore(destination: string, numkeys: number, key: KeyType, ...args: string[]): Pipeline;
1350
1351 zinterstore(destination: string, numkeys: number, key: KeyType, ...args: string[]): Pipeline;
1352
1353 zrange(key: KeyType, start: number, stop: number, callback?: Callback<string[]>): Pipeline;
1354 zrange(
1355 key: KeyType,
1356 start: number,
1357 stop: number,
1358 withScores: 'WITHSCORES',
1359 callback?: Callback<string[]>,
1360 ): Pipeline;
1361
1362 zrevrange(key: KeyType, start: number, stop: number, callback?: Callback<string[]>): Pipeline;
1363 zrevrange(
1364 key: KeyType,
1365 start: number,
1366 stop: number,
1367 withScores: 'WITHSCORES',
1368 callback?: Callback<string[]>,
1369 ): Pipeline;
1370
1371 zrangebyscore(key: KeyType, min: number | string, max: number | string, ...args: string[]): Pipeline;
1372
1373 zrevrangebyscore(key: KeyType, max: number | string, min: number | string, ...args: string[]): Pipeline;
1374
1375 zrangebylex(
1376 key: KeyType,
1377 min: string,
1378 max: string,
1379 callback?: Callback<string[]>,
1380 ): Pipeline;
1381 zrangebylex(
1382 key: KeyType,
1383 min: string,
1384 max: string,
1385 limit: 'LIMIT',
1386 offset: number,
1387 count: number,
1388 callback?: Callback<string[]>,
1389 ): Pipeline;
1390 zrevrangebylex(
1391 key: KeyType,
1392 min: string,
1393 max: string,
1394 callback?: Callback<string[]>,
1395 ): Pipeline;
1396 zrevrangebylex(
1397 key: KeyType,
1398 min: string,
1399 max: string,
1400 limit: 'LIMIT',
1401 offset: number,
1402 count: number,
1403 callback?: Callback<string[]>,
1404 ): Pipeline;
1405
1406 zcount(key: KeyType, min: number | string, max: number | string, callback?: Callback<number>): Pipeline;
1407
1408 zcard(key: KeyType, callback?: Callback<number>): Pipeline;
1409
1410 zscore(key: KeyType, member: string, callback?: Callback<number>): Pipeline;
1411
1412 zrank(key: KeyType, member: string, callback?: Callback<number>): Pipeline;
1413
1414 zrevrank(key: KeyType, member: string, callback?: Callback<number>): Pipeline;
1415
1416 hset(key: KeyType, ...args: ValueType[]): Pipeline;
1417 hset(key: KeyType, data: object | Map<string, any>, callback?: Callback<BooleanResponse>): Pipeline;
1418 hset(key: KeyType, field: string, value: ValueType, callback?: Callback<BooleanResponse>): Pipeline;
1419 hsetBuffer(key: KeyType, field: string, value: ValueType, callback?: Callback<Buffer>): Pipeline;
1420
1421 hsetnx(key: KeyType, field: string, value: ValueType, callback?: Callback<BooleanResponse>): Pipeline;
1422
1423 hget(key: KeyType, field: string, callback?: Callback<string | string>): Pipeline;
1424 hgetBuffer(key: KeyType, field: string, callback?: Callback<Buffer>): Pipeline;
1425
1426 hmset(key: KeyType, ...args: ValueType[]): Pipeline;
1427 hmset(key: KeyType, data: object | Map<string, any>, callback?: Callback<BooleanResponse>): Pipeline;
1428
1429 hmget(key: KeyType, ...fields: string[]): Pipeline;
1430
1431 hstrlen(key: KeyType, field: string, callback?: Callback<number>): Pipeline;
1432
1433 hincrby(key: KeyType, field: string, increment: number, callback?: Callback<number>): Pipeline;
1434
1435 hincrbyfloat(key: KeyType, field: string, increment: number, callback?: Callback<number>): Pipeline;
1436
1437 hdel(key: KeyType, ...fields: string[]): Pipeline;
1438
1439 hlen(key: KeyType, callback?: Callback<number>): Pipeline;
1440
1441 hkeys(key: KeyType, callback?: Callback<string[]>): Pipeline;
1442
1443 hvals(key: KeyType, callback?: Callback<string[]>): Pipeline;
1444
1445 hgetall(key: KeyType, callback?: Callback<Record<string, string>>): Pipeline;
1446
1447 hexists(key: KeyType, field: string, callback?: Callback<BooleanResponse>): Pipeline;
1448
1449 geoadd(key: KeyType, longitude: number, latitude: number, member: string, callback?: Callback<number>): Pipeline;
1450
1451 geodist(key: KeyType, member1: string, member2: string, unit: 'm'|'km'|'ft'|'mi', callback?: Callback<string | null>): Pipeline;
1452
1453 geohash(key: KeyType, ...fields: string[]): Pipeline;
1454
1455 geopos(key: KeyType, ...fields: string[]): Pipeline;
1456
1457 georadius(key: KeyType, longitude: number, latitude: number, radius: number, unit: 'm'|'km'|'ft'|'mi', callback?: Callback<string[]>): Pipeline;
1458 georadius(key: KeyType, longitude: number, latitude: number, radius: number, unit: 'm'|'km'|'ft'|'mi', count: 'COUNT', countValue: number, callback?: Callback<string[]>): Pipeline;
1459
1460 georadiusbymember(key: KeyType, member: string, radius: number, unit: 'm'|'km'|'ft'|'mi', callback?: Callback<string[]>): Pipeline;
1461 georadiusbymember(key: KeyType, member: string, radius: number, unit: 'm'|'km'|'ft'|'mi', count: 'COUNT', countValue: number, callback?: Callback<string[]>): Pipeline;
1462
1463 incrby(key: KeyType, increment: number, callback?: Callback<number>): Pipeline;
1464
1465 incrbyfloat(key: KeyType, increment: number, callback?: Callback<number>): Pipeline;
1466
1467 decrby(key: KeyType, decrement: number, callback?: Callback<number>): Pipeline;
1468
1469 getset(key: KeyType, value: ValueType, callback?: Callback<string>): Pipeline;
1470
1471 mset(...args: ValueType[]): Pipeline;
1472 mset(data: object | Map<string, any>, callback?: Callback<string>): Pipeline;
1473
1474 msetnx(...args: ValueType[]): Pipeline;
1475 msetnx(data: object | Map<string, any>, callback?: Callback<BooleanResponse>): Pipeline;
1476
1477 memory(argument: 'USAGE', key: KeyType, callback?: Callback<number>): Pipeline;
1478
1479 randomkey(callback?: Callback<string>): Pipeline;
1480
1481 select(index: number, callback?: Callback<string>): Pipeline;
1482
1483 move(key: KeyType, db: string, callback?: Callback<BooleanResponse>): Pipeline;
1484
1485 rename(key: KeyType, newkey: KeyType, callback?: Callback<string>): Pipeline;
1486
1487 renamenx(key: KeyType, newkey: KeyType, callback?: Callback<BooleanResponse>): Pipeline;
1488
1489 expire(key: KeyType, seconds: number, callback?: Callback<BooleanResponse>): Pipeline;
1490
1491 pexpire(key: KeyType, milliseconds: number, callback?: Callback<BooleanResponse>): Pipeline;
1492
1493 expireat(key: KeyType, timestamp: number, callback?: Callback<BooleanResponse>): Pipeline;
1494
1495 pexpireat(key: KeyType, millisecondsTimestamp: number, callback?: Callback<BooleanResponse>): Pipeline;
1496
1497 keys(pattern: string, callback?: Callback<string[]>): Pipeline;
1498
1499 dbsize(callback?: Callback<number>): Pipeline;
1500
1501 auth(password: string, callback?: Callback<string>): Pipeline;
1502 auth(username: string, password: string, callback?: Callback<string>): Pipeline;
1503
1504 ping(callback?: Callback<string>): Pipeline;
1505 ping(message: string, callback?: Callback<string>): Pipeline;
1506
1507 echo(message: string, callback?: Callback<string>): Pipeline;
1508
1509 save(callback?: Callback<string>): Pipeline;
1510
1511 bgsave(callback?: Callback<string>): Pipeline;
1512
1513 bgrewriteaof(callback?: Callback<string>): Pipeline;
1514
1515 shutdown(save: 'SAVE' | 'NOSAVE', callback?: Callback<never>): Pipeline;
1516
1517 lastsave(callback?: Callback<number>): Pipeline;
1518
1519 type(key: KeyType, callback?: Callback<string>): Pipeline;
1520
1521 multi(callback?: Callback<string>): Pipeline;
1522
1523 exec(callback?: Callback<Array<[Error | null, any]>>): Promise<Array<[Error | null, any]>>;
1524
1525 discard(callback?: Callback<any>): Pipeline;
1526
1527 sync(callback?: Callback<any>): Pipeline;
1528
1529 flushdb(callback?: Callback<string>): Pipeline;
1530
1531 flushall(callback?: Callback<string>): Pipeline;
1532
1533 sort(key: KeyType, ...args: string[]): Pipeline;
1534
1535 info(callback?: Callback<string>): Pipeline;
1536 info(section: string, callback?: Callback<string>): Pipeline;
1537
1538 time(callback?: Callback<[string, string]>): Pipeline;
1539
1540 monitor(callback?: Callback<EventEmitter>): Pipeline;
1541
1542 ttl(key: KeyType, callback?: Callback<number>): Pipeline;
1543
1544 pttl(key: KeyType, callback?: Callback<number>): Pipeline;
1545
1546 persist(key: KeyType, callback?: Callback<BooleanResponse>): Pipeline;
1547
1548 slaveof(host: string, port: number, callback?: Callback<string>): Pipeline;
1549
1550 debug(...args: ValueType[]): Pipeline;
1551
1552 config(...args: ValueType[]): Pipeline;
1553
1554 subscribe(...channels: ValueType[]): Pipeline;
1555
1556 unsubscribe(...channels: string[]): Pipeline;
1557
1558 psubscribe(...patterns: string[]): Pipeline;
1559
1560 punsubscribe(...patterns: string[]): Pipeline;
1561
1562 publish(channel: string, message: string, callback?: Callback<number>): Pipeline;
1563
1564 watch(...keys: KeyType[]): Pipeline;
1565
1566 unwatch(callback?: Callback<string>): Pipeline;
1567
1568 cluster(...args: ValueType[]): Pipeline;
1569
1570 restore(...args: ValueType[]): Pipeline;
1571
1572 migrate(...args: ValueType[]): Pipeline;
1573
1574 dump(key: KeyType, callback?: Callback<string>): Pipeline;
1575
1576 object(subcommand: string, ...args: ValueType[]): Pipeline;
1577
1578 client(...args: ValueType[]): Pipeline;
1579
1580 eval(script: string, numKeys: number, ...args: ValueType[]): Pipeline;
1581
1582 evalsha(scriptSha: string, numKeys: string, ...args: ValueType[]): Pipeline;
1583
1584 script(...args: ValueType[]): Pipeline;
1585
1586 quit(callback?: Callback<string>): Pipeline;
1587
1588 scan(cursor: number | string): Pipeline;
1589
1590 scan(cursor: number | string, matchOption: 'match' | 'MATCH', pattern: string): Pipeline;
1591 scan(cursor: number | string, countOption: 'count' | 'COUNT', count: number): Pipeline;
1592
1593 scan(
1594 cursor: number | string,
1595 matchOption: 'match' | 'MATCH',
1596 pattern: string,
1597 countOption: 'count' | 'COUNT',
1598 count: number,
1599 ): Pipeline;
1600 scan(
1601 cursor: number | string,
1602 countOption: 'count' | 'COUNT',
1603 count: number,
1604 matchOption: 'match' | 'MATCH',
1605 pattern: string,
1606 ): Pipeline;
1607 sscan(key: KeyType, cursor: number | string, ...args: ValueType[]): Pipeline;
1608
1609 hscan(key: KeyType, cursor: number | string, ...args: ValueType[]): Pipeline;
1610
1611 zscan(key: KeyType, cursor: number | string, ...args: ValueType[]): Pipeline;
1612
1613 pfmerge(destkey: KeyType, ...sourcekeys: KeyType[]): Pipeline;
1614
1615 pfadd(key: KeyType, ...elements: string[]): Pipeline;
1616
1617 pfcount(...keys: KeyType[]): Pipeline;
1618
1619 xack(key: KeyType, group: string, ...ids: string[]): Pipeline;
1620
1621 xadd(key: KeyType, id: string, ...args: string[]): Pipeline;
1622
1623 xclaim(
1624 key: KeyType,
1625 group: string,
1626 consumer: string,
1627 minIdleTime: number,
1628 id: string,
1629 ...args: ValueType[]
1630 ): Pipeline;
1631
1632 xdel(key: KeyType, ...ids: string[]): Pipeline;
1633
1634 xgroup(...args: ValueType[]): Pipeline;
1635
1636 xinfo(...args: ValueType[]): Pipeline;
1637
1638 xlen(key: KeyType): Pipeline;
1639
1640 xpending(key: KeyType, group: string, ...args: ValueType[]): Pipeline;
1641
1642 xrange(key: KeyType, start: string, end: string, ...args: ValueType[]): Pipeline;
1643
1644 xread(...args: ValueType[]): Pipeline;
1645
1646 xreadgroup(command: 'GROUP' | 'group', group: string, consumer: string, ...args: ValueType[]): Pipeline;
1647
1648 xrevrange(key: KeyType, end: string, start: string, ...args: ValueType[]): Pipeline;
1649
1650 xtrim(key: KeyType, strategy: 'MAXLEN' | 'maxlen', ...args: ValueType[]): Pipeline;
1651 }
1652
1653 interface NodeConfiguration {
1654 host?: string;
1655 port?: number;
1656 }
1657
1658 type ClusterNode = string | number | NodeConfiguration;
1659
1660 type NodeRole = 'master' | 'slave' | 'all';
1661
1662 type CallbackFunction<T = any> = (err?: NodeJS.ErrnoException | null, result?: T) => void;
1663
1664 type Ok = 'OK';
1665
1666 interface Cluster extends EventEmitter, Commander, Commands {
1667 readonly options: ClusterOptions;
1668 readonly status: string;
1669 connect(): Promise<void>;
1670 disconnect(): void;
1671 nodes(role?: NodeRole): Redis[];
1672 }
1673
1674 interface ClusterStatic extends EventEmitter {
1675 new (nodes: ClusterNode[], options?: ClusterOptions): Cluster;
1676 }
1677
1678 interface RedisOptions {
1679 port?: number;
1680 host?: string;
1681 /**
1682 * 4 (IPv4) or 6 (IPv6), Defaults to 4.
1683 */
1684 family?: number;
1685 /**
1686 * Local domain socket path. If set the port, host and family will be ignored.
1687 */
1688 path?: string;
1689 /**
1690 * TCP KeepAlive on the socket with a X ms delay before start. Set to a non-number value to disable keepAlive.
1691 */
1692 keepAlive?: number;
1693 connectionName?: string;
1694 /**
1695 * If set, client will send AUTH command with the value of this option as the first argument when connected. The `password` option must be set too. Username should only be set for Redis >=6.
1696 */
1697 username?: string;
1698 /**
1699 * If set, client will send AUTH command with the value of this option when connected.
1700 */
1701 password?: string;
1702 /**
1703 * Database index to use.
1704 */
1705 db?: number;
1706 /**
1707 * When a connection is established to the Redis server, the server might still be loading
1708 * the database from disk. While loading, the server not respond to any commands.
1709 * To work around this, when this option is true, ioredis will check the status of the Redis server,
1710 * and when the Redis server is able to process commands, a ready event will be emitted.
1711 */
1712 enableReadyCheck?: boolean;
1713 keyPrefix?: string;
1714 /**
1715 * When the return value isn't a number, ioredis will stop trying to reconnect.
1716 * Fixed in: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/15858
1717 */
1718 retryStrategy?(times: number): number | void | null;
1719 /**
1720 * By default, all pending commands will be flushed with an error every
1721 * 20 retry attempts. That makes sure commands won't wait forever when
1722 * the connection is down. You can change this behavior by setting
1723 * `maxRetriesPerRequest`.
1724 *
1725 * Set maxRetriesPerRequest to `null` to disable this behavior, and
1726 * every command will wait forever until the connection is alive again
1727 * (which is the default behavior before ioredis v4).
1728 */
1729 maxRetriesPerRequest?: number | null;
1730 /**
1731 * 1/true means reconnect, 2 means reconnect and resend failed command. Returning false will ignore
1732 * the error and do nothing.
1733 */
1734 reconnectOnError?(error: Error): boolean | 1 | 2;
1735 /**
1736 * By default, if there is no active connection to the Redis server, commands are added to a queue
1737 * and are executed once the connection is "ready" (when enableReadyCheck is true, "ready" means
1738 * the Redis server has loaded the database from disk, otherwise means the connection to the Redis
1739 * server has been established). If this option is false, when execute the command when the connection
1740 * isn't ready, an error will be returned.
1741 */
1742 enableOfflineQueue?: boolean;
1743 /**
1744 * The milliseconds before a timeout occurs during the initial connection to the Redis server.
1745 * default: 10000.
1746 */
1747 connectTimeout?: number;
1748 /**
1749 * After reconnected, if the previous connection was in the subscriber mode, client will auto re-subscribe these channels.
1750 * default: true.
1751 */
1752 autoResubscribe?: boolean;
1753 /**
1754 * If true, client will resend unfulfilled commands(e.g. block commands) in the previous connection when reconnected.
1755 * default: true.
1756 */
1757 autoResendUnfulfilledCommands?: boolean;
1758 lazyConnect?: boolean;
1759 tls?: ConnectionOptions;
1760 /**
1761 * default: "master".
1762 */
1763 role?: 'master' | 'slave';
1764 /**
1765 * default: null.
1766 */
1767 name?: string;
1768 sentinelUsername?: string;
1769 sentinelPassword?: string;
1770 sentinels?: Array<{ host: string; port: number }>;
1771 /**
1772 * If `sentinelRetryStrategy` returns a valid delay time, ioredis will try to reconnect from scratch.
1773 * default: function(times) { return Math.min(times * 10, 1000); }
1774 */
1775 sentinelRetryStrategy?(times: number): number | void | null;
1776 /**
1777 * Can be used to prefer a particular slave or set of slaves based on priority.
1778 */
1779 preferredSlaves?: PreferredSlaves;
1780 /**
1781 * Whether to support the `tls` option when connecting to Redis via sentinel mode.
1782 * default: false.
1783 */
1784 enableTLSForSentinelMode?: boolean;
1785 sentinelTLS?: SecureContextOptions;
1786 /**
1787 * NAT map for sentinel connector.
1788 * default: null.
1789 */
1790 natMap?: NatMap;
1791 /**
1792 * Update the given `sentinels` list with new IP addresses when communicating with existing sentinels.
1793 * default: true.
1794 */
1795 updateSentinels?: boolean;
1796 /**
1797 * Enable READONLY mode for the connection. Only available for cluster mode.
1798 * default: false.
1799 */
1800 readOnly?: boolean;
1801 /**
1802 * If you are using the hiredis parser, it's highly recommended to enable this option.
1803 * Create another instance with dropBufferSupport disabled for other commands that you want to return binary instead of string
1804 */
1805 dropBufferSupport?: boolean;
1806 /**
1807 * Whether to show a friendly error stack. Will decrease the performance significantly.
1808 */
1809 showFriendlyErrorStack?: boolean;
1810 /**
1811 * When enabled, all commands issued during an event loop iteration are automatically wrapped in a
1812 * pipeline and sent to the server at the same time. This can improve performance by 30-50%.
1813 * default: false.
1814 */
1815 enableAutoPipelining?: boolean;
1816 }
1817
1818 interface AddressFromResponse {
1819 port: string;
1820 ip: string;
1821 flags?: string;
1822 }
1823
1824 type PreferredSlaves =
1825 | ((slaves: AddressFromResponse[]) => AddressFromResponse | null)
1826 | Array<{ port: string; ip: string; prio?: number }>
1827 | { port: string; ip: string; prio?: number };
1828
1829 type SecureVersion = 'TLSv1.3' | 'TLSv1.2' | 'TLSv1.1' | 'TLSv1';
1830
1831 interface SecureContextOptions {
1832 pfx?: string | Buffer | Array<string | Buffer | object>;
1833 key?: string | Buffer | Array<Buffer | object>;
1834 passphrase?: string;
1835 cert?: string | Buffer | Array<string | Buffer>;
1836 ca?: string | Buffer | Array<string | Buffer>;
1837 ciphers?: string;
1838 honorCipherOrder?: boolean;
1839 ecdhCurve?: string;
1840 clientCertEngine?: string;
1841 crl?: string | Buffer | Array<string | Buffer>;
1842 dhparam?: string | Buffer;
1843 secureOptions?: number; // Value is a numeric bitmask of the `SSL_OP_*` options
1844 secureProtocol?: string; // SSL Method, e.g. SSLv23_method
1845 sessionIdContext?: string;
1846 /**
1847 * Optionally set the maximum TLS version to allow. One
1848 * of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the
1849 * `secureProtocol` option, use one or the other.
1850 * **Default:** `'TLSv1.3'`, unless changed using CLI options. Using
1851 * `--tls-max-v1.2` sets the default to `'TLSv1.2'`. Using `--tls-max-v1.3` sets the default to
1852 * `'TLSv1.3'`. If multiple of the options are provided, the highest maximum is used.
1853 */
1854 maxVersion?: SecureVersion;
1855 /**
1856 * Optionally set the minimum TLS version to allow. One
1857 * of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the
1858 * `secureProtocol` option, use one or the other. It is not recommended to use
1859 * less than TLSv1.2, but it may be required for interoperability.
1860 * **Default:** `'TLSv1.2'`, unless changed using CLI options. Using
1861 * `--tls-v1.0` sets the default to `'TLSv1'`. Using `--tls-v1.1` sets the default to
1862 * `'TLSv1.1'`. Using `--tls-min-v1.3` sets the default to
1863 * 'TLSv1.3'. If multiple of the options are provided, the lowest minimum is used.
1864 */
1865 minVersion?: SecureVersion;
1866 }
1867
1868 interface ScanStreamOption {
1869 match?: string;
1870 count?: number;
1871 }
1872
1873 type DNSLookupFunction = (
1874 hostname: string,
1875 callback: (err: NodeJS.ErrnoException | null, address: string, family?: number) => void,
1876 ) => void;
1877 interface NatMap {
1878 [key: string]: { host: string; port: number };
1879 }
1880
1881 interface ClusterOptions {
1882 clusterRetryStrategy?(times: number, reason?: Error): number | null;
1883 enableOfflineQueue?: boolean;
1884 enableReadyCheck?: boolean;
1885 scaleReads?: string;
1886 maxRedirections?: number;
1887 retryDelayOnFailover?: number;
1888 retryDelayOnClusterDown?: number;
1889 retryDelayOnTryAgain?: number;
1890 slotsRefreshTimeout?: number;
1891 slotsRefreshInterval?: number;
1892 redisOptions?: RedisOptions;
1893 lazyConnect?: boolean;
1894 dnsLookup?: DNSLookupFunction;
1895 natMap?: NatMap;
1896 }
1897
1898 interface MultiOptions {
1899 pipeline: boolean;
1900 }
1901}