UNPKG

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