UNPKG

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