UNPKG

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