UNPKG

55.3 kBTypeScriptView Raw
1// Type definitions for redis 2.8
2// Project: https://github.com/NodeRedis/node_redis
3// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
4// Peter Harris <https://github.com/CodeAnimal>
5// TANAKA Koichi <https://github.com/MugeSo>
6// Stuart Schechter <https://github.com/UppaJung>
7// Junyoung Choi <https://github.com/Rokt33r>
8// James Garbutt <https://github.com/43081j>
9// Bartek Szczepański <https://github.com/barnski>
10// Pirasis Leelatanon <https://github.com/1pete>
11// Stanislav Dzhus <https://github.com/blablapolicja>
12// Jake Ferrante <https://github.com/ferrantejake>
13// Adebayo Opesanya <https://github.com/OpesanyaAdebayo>
14// Ryo Ota <https://github.com/nwtgck>
15// Thomas de Barochez <https://github.com/tdebarochez>
16// David Stephens <https://github.com/dwrss>
17// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
18
19// Imported from: https://github.com/types/npm-redis
20
21/// <reference types="node" />
22
23import { EventEmitter } from 'events';
24import { Duplex } from 'stream';
25
26export interface RetryStrategyOptions {
27 error: NodeJS.ErrnoException;
28 total_retry_time: number;
29 times_connected: number;
30 attempt: number;
31}
32
33export type RetryStrategy = (options: RetryStrategyOptions) => number | Error | unknown;
34
35/**
36 * Client options.
37 * @see https://github.com/NodeRedis/node-redis#user-content-options-object-properties
38 */
39export interface ClientOpts {
40 /**
41 * IP address of the Redis server.
42 * @default 127.0.0.1
43 */
44 host?: string | undefined;
45 /**
46 * Port of the Redis server.
47 * @default 6379
48 */
49 port?: number | undefined;
50 /**
51 * The UNIX socket string of the Redis server.
52 * @default null
53 */
54 path?: string | undefined;
55 /**
56 * The URL of the Redis server.\
57 * Format:
58 * [redis[s]:]//[[user][:password@]][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]\
59 * More info avaliable at [IANA](http://www.iana.org/assignments/uri-schemes/prov/redis).
60 * @default null
61 */
62 url?: string | undefined;
63 parser?: string | undefined;
64 /**
65 * Set to `true`, Node Redis will return Redis number values as Strings instead of javascript Numbers.
66 * Useful if you need to handle big numbers (above `Number.MAX_SAFE_INTEGER` === 2^53).
67 * Hiredis is incapable of this behavior, so setting this option to `true`
68 * will result in the built-in javascript parser being used no matter
69 * the value of the `parser` option.
70 * @default null
71 */
72 string_numbers?: boolean | undefined;
73 /**
74 * If set to `true`, then all replies will be sent to callbacks as Buffers instead of Strings.
75 * @default false
76 */
77 return_buffers?: boolean | undefined;
78 /**
79 * If set to `true`, then replies will be sent to callbacks as Buffers.
80 * This option lets you switch between Buffers and Strings on a per-command basis,
81 * whereas `return_buffers` applies to every command on a client.\
82 * **Note**: This doesn't work properly with the pubsub mode.
83 * A subscriber has to either always return Strings or Buffers.
84 * @default false
85 */
86 detect_buffers?: boolean | undefined;
87 /**
88 * If set to `true`, the keep-alive functionality is enabled on the underlying socket.
89 * @default true
90 */
91 socket_keepalive?: boolean | undefined;
92 /**
93 * Initial Delay in milliseconds.
94 * This will also set the initial delay for keep-alive packets being sent to Redis.
95 * @default 0
96 */
97 socket_initial_delay?: number | undefined;
98 /**
99 * When a connection is established to the Redis server,
100 * the server might still be loading the database from disk.
101 * While loading, the server will not respond to any commands.
102 * To work around this, Node Redis has a "ready check" which sends the **INFO** command to the server.
103 * The response from the **INFO** command indicates whether the server is ready for more commands.
104 * When ready, **node_redis** emits a **ready** event.
105 * Setting `no_ready_check` to `true` will inhibit this check.
106 * @default false
107 */
108 no_ready_check?: boolean | undefined;
109 /**
110 * By default, if there is no active connection to the Redis server,
111 * commands are added to a queue and are executed once the connection has been established.
112 * Setting `enable_offline_queue` to `false` will disable this feature
113 * and the callback will be executed immediately with an error,
114 * or an error will be emitted if no callback is specified.
115 * @default true
116 */
117 enable_offline_queue?: boolean | undefined;
118 retry_max_delay?: number | undefined;
119 connect_timeout?: number | undefined;
120 max_attempts?: number | undefined;
121 /**
122 * If set to `true`, all commands that were unfulfilled while the connection is lost
123 * will be retried after the connection has been reestablished.
124 * Use this with caution if you use state altering commands (e.g. incr).
125 * This is especially useful if you use blocking commands.
126 * @default false
127 */
128 retry_unfulfilled_commands?: boolean | undefined;
129 auth_pass?: string | undefined;
130 /**
131 * If set, client will run Redis auth command on connect.
132 * Alias `auth_pass`.\
133 * **Note**: Node Redis < 2.5 must use `auth_pass`.
134 * @default null
135 */
136 password?: string | undefined;
137 /**
138 * If set, client will run Redis **select** command on connect.
139 * @default null
140 */
141 db?: string | number | undefined;
142 /**
143 * You can force using IPv6 if you set the family to **IPv6**.
144 * @see Node.js [net](https://nodejs.org/api/net.html)
145 * or [dns](https://nodejs.org/api/dns.html)
146 * modules on how to use the family type.
147 * @default IPv4
148 */
149 family?: string | undefined;
150 /**
151 * If set to `true`, a client won't resubscribe after disconnecting.
152 * @default false
153 */
154 disable_resubscribing?: boolean | undefined;
155 /**
156 * Passing an object with renamed commands to use instead of the original functions.
157 * For example, if you renamed the command **KEYS** to "DO-NOT-USE"
158 * then the `rename_commands` object would be: { KEYS : "DO-NOT-USE" }.
159 * @see the [Redis security topics](http://redis.io/topics/security) for more info.
160 * @default null
161 */
162 rename_commands?: { [command: string]: string } | null | undefined;
163 /**
164 * An object containing options to pass to
165 * [tls.connect](http://nodejs.org/api/tls.html#tls_tls_connect_port_host_options_callback)
166 * to set up a TLS connection to Redis
167 * (if, for example, it is set up to be accessible via a tunnel).
168 * @default null
169 */
170 tls?: any;
171 /**
172 * A string used to prefix all used keys (e.g. namespace:test).
173 * Please be aware that the **keys** command will not be prefixed.
174 * The **keys** command has a "pattern" as argument and no key
175 * and it would be impossible to determine the existing keys in Redis if this would be prefixed.
176 * @default null
177 */
178 prefix?: string | undefined;
179 /**
180 * A function that receives an options object as parameter including the retry `attempt`,
181 * the `total_retry_time` indicating how much time passed since the last time connected,
182 * the **error** why the connection was lost and the number of `times_connected` in total.
183 * If you return a number from this function, the retry will happen after that time in milliseconds.
184 * If you return a non-number, no further retry will happen
185 * and all offline commands are flushed with errors.
186 * Return an error to return that specific error to all offline commands.
187 * @default function
188 * @see interface `RetryStrategyOptions`
189 * @example
190 * const client = redis.createClient({
191 * retry_strategy: function(options) {
192 * if (options.error && options.error.code === "ECONNREFUSED") {
193 * // End reconnecting on a specific error and flush all commands with
194 * // a individual error
195 * return new Error("The server refused the connection");
196 * }
197 * if (options.total_retry_time > 1000 * 60 * 60) {
198 * // End reconnecting after a specific timeout and flush all commands
199 * // with a individual error
200 * return new Error("Retry time exhausted");
201 * }
202 * if (options.attempt > 10) {
203 * // End reconnecting with built in error
204 * return undefined;
205 * }
206 * // reconnect after
207 * return Math.min(options.attempt * 100, 3000);
208 * }
209 * });
210 */
211 retry_strategy?: RetryStrategy | undefined;
212}
213
214export type Callback<T> = (err: Error | null, reply: T) => void;
215
216export interface ServerInfo {
217 redis_version: string;
218 versions: number[];
219}
220
221export interface OverloadedCommand<T, U, R> {
222 (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb?: Callback<U>): R;
223 (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, cb?: Callback<U>): R;
224 (arg1: T, arg2: T, arg3: T, arg4: T, cb?: Callback<U>): R;
225 (arg1: T, arg2: T, arg3: T, cb?: Callback<U>): R;
226 (arg1: T, arg2: T | T[], cb?: Callback<U>): R;
227 (arg1: T | T[], cb?: Callback<U>): R;
228 (...args: Array<T | Callback<U>>): R;
229}
230
231export interface OverloadedKeyCommand<T, U, R> {
232 (key: string, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb?: Callback<U>): R;
233 (key: string, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, cb?: Callback<U>): R;
234 (key: string, arg1: T, arg2: T, arg3: T, arg4: T, cb?: Callback<U>): R;
235 (key: string, arg1: T, arg2: T, arg3: T, cb?: Callback<U>): R;
236 (key: string, arg1: T, arg2: T, cb?: Callback<U>): R;
237 (key: string, arg1: T | T[], cb?: Callback<U>): R;
238 (key: string, ...args: Array<T | Callback<U>>): R;
239 (...args: Array<string | T | Callback<U>>): R;
240}
241
242export interface OverloadedListCommand<T, U, R> {
243 (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb?: Callback<U>): R;
244 (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, cb?: Callback<U>): R;
245 (arg1: T, arg2: T, arg3: T, arg4: T, cb?: Callback<U>): R;
246 (arg1: T, arg2: T, arg3: T, cb?: Callback<U>): R;
247 (arg1: T, arg2: T, cb?: Callback<U>): R;
248 (arg1: T | T[], cb?: Callback<U>): R;
249 (...args: Array<T | Callback<U>>): R;
250}
251
252export interface OverloadedSetCommand<T, U, R> {
253 (key: string, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb?: Callback<U>): R;
254 (key: string, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, cb?: Callback<U>): R;
255 (key: string, arg1: T, arg2: T, arg3: T, arg4: T, cb?: Callback<U>): R;
256 (key: string, arg1: T, arg2: T, arg3: T, cb?: Callback<U>): R;
257 (key: string, arg1: T, arg2: T, cb?: Callback<U>): R;
258 (key: string, arg1: T | { [key: string]: T } | T[], cb?: Callback<U>): R;
259 (key: string, ...args: Array<T | Callback<U>>): R;
260 (args: [string, ...T[]], cb?: Callback<U>): R;
261}
262
263export interface OverloadedLastCommand<T1, T2, U, R> {
264 (arg1: T1, arg2: T1, arg3: T1, arg4: T1, arg5: T1, arg6: T2, cb?: Callback<U>): R;
265 (arg1: T1, arg2: T1, arg3: T1, arg4: T1, arg5: T2, cb?: Callback<U>): R;
266 (arg1: T1, arg2: T1, arg3: T1, arg4: T2, cb?: Callback<U>): R;
267 (arg1: T1, arg2: T1, arg3: T2, cb?: Callback<U>): R;
268 (arg1: T1, arg2: T2 | Array<T1 | T2>, cb?: Callback<U>): R;
269 (args: Array<T1 | T2>, cb?: Callback<U>): R;
270 (...args: Array<T1 | T2 | Callback<U>>): R;
271}
272
273export interface Commands<R> {
274 /**
275 * Listen for all requests received by the server in real time.
276 */
277 monitor(cb?: Callback<undefined>): R;
278 MONITOR(cb?: Callback<undefined>): R;
279
280 /**
281 * Get information and statistics about the server.
282 */
283 info(cb?: Callback<ServerInfo>): R;
284 info(section?: string | string[], cb?: Callback<ServerInfo>): R;
285 INFO(cb?: Callback<ServerInfo>): R;
286 INFO(section?: string | string[], cb?: Callback<ServerInfo>): R;
287
288 /**
289 * Ping the server.
290 */
291 ping(callback?: Callback<string>): R;
292 ping(message: string, callback?: Callback<string>): R;
293 PING(callback?: Callback<string>): R;
294 PING(message: string, callback?: Callback<string>): R;
295
296 /**
297 * Post a message to a channel.
298 */
299 publish(channel: string, value: string, cb?: Callback<number>): R;
300 PUBLISH(channel: string, value: string, cb?: Callback<number>): R;
301
302 /**
303 * Authenticate to the server.
304 */
305 auth(password: string, callback?: Callback<string>): R;
306 AUTH(password: string, callback?: Callback<string>): R;
307
308 /**
309 * KILL - Kill the connection of a client.
310 * LIST - Get the list of client connections.
311 * GETNAME - Get the current connection name.
312 * PAUSE - Stop processing commands from clients for some time.
313 * REPLY - Instruct the server whether to reply to commands.
314 * SETNAME - Set the current connection name.
315 */
316 client: OverloadedCommand<string, any, R>;
317 CLIENT: OverloadedCommand<string, any, R>;
318
319 /**
320 * Set multiple hash fields to multiple values.
321 */
322 hmset: OverloadedSetCommand<string | number, 'OK', R>;
323 HMSET: OverloadedSetCommand<string | number, 'OK', R>;
324
325 /**
326 * Listen for messages published to the given channels.
327 */
328 subscribe: OverloadedListCommand<string, string, R>;
329 SUBSCRIBE: OverloadedListCommand<string, string, R>;
330
331 /**
332 * Stop listening for messages posted to the given channels.
333 */
334 unsubscribe: OverloadedListCommand<string, string, R>;
335 UNSUBSCRIBE: OverloadedListCommand<string, string, R>;
336
337 /**
338 * Listen for messages published to channels matching the given patterns.
339 */
340 psubscribe: OverloadedListCommand<string, string, R>;
341 PSUBSCRIBE: OverloadedListCommand<string, string, R>;
342
343 /**
344 * Stop listening for messages posted to channels matching the given patterns.
345 */
346 punsubscribe: OverloadedListCommand<string, string, R>;
347 PUNSUBSCRIBE: OverloadedListCommand<string, string, R>;
348
349 /**
350 * Append a value to a key.
351 */
352 append(key: string, value: string, cb?: Callback<number>): R;
353 APPEND(key: string, value: string, cb?: Callback<number>): R;
354
355 /**
356 * Asynchronously rewrite the append-only file.
357 */
358 bgrewriteaof(cb?: Callback<'OK'>): R;
359 BGREWRITEAOF(cb?: Callback<'OK'>): R;
360
361 /**
362 * Asynchronously save the dataset to disk.
363 */
364 bgsave(cb?: Callback<string>): R;
365 BGSAVE(cb?: Callback<string>): R;
366
367 /**
368 * Count set bits in a string.
369 */
370 bitcount(key: string, cb?: Callback<number>): R;
371 bitcount(key: string, start: number, end: number, cb?: Callback<number>): R;
372 BITCOUNT(key: string, cb?: Callback<number>): R;
373 BITCOUNT(key: string, start: number, end: number, cb?: Callback<number>): R;
374
375 /**
376 * Perform arbitrary bitfield integer operations on strings.
377 */
378 bitfield: OverloadedKeyCommand<string | number, number[], R>;
379 BITFIELD: OverloadedKeyCommand<string | number, number[], R>;
380
381 /**
382 * Perform bitwise operations between strings.
383 */
384 bitop(operation: string, destkey: string, key1: string, key2: string, key3: string, cb?: Callback<number>): R;
385 bitop(operation: string, destkey: string, key1: string, key2: string, cb?: Callback<number>): R;
386 bitop(operation: string, destkey: string, key: string, cb?: Callback<number>): R;
387 bitop(operation: string, destkey: string, ...args: Array<string | Callback<number>>): R;
388 BITOP(operation: string, destkey: string, key1: string, key2: string, key3: string, cb?: Callback<number>): R;
389 BITOP(operation: string, destkey: string, key1: string, key2: string, cb?: Callback<number>): R;
390 BITOP(operation: string, destkey: string, key: string, cb?: Callback<number>): R;
391 BITOP(operation: string, destkey: string, ...args: Array<string | Callback<number>>): R;
392
393 /**
394 * Find first bit set or clear in a string.
395 */
396 bitpos(key: string, bit: number, start: number, end: number, cb?: Callback<number>): R;
397 bitpos(key: string, bit: number, start: number, cb?: Callback<number>): R;
398 bitpos(key: string, bit: number, cb?: Callback<number>): R;
399 BITPOS(key: string, bit: number, start: number, end: number, cb?: Callback<number>): R;
400 BITPOS(key: string, bit: number, start: number, cb?: Callback<number>): R;
401 BITPOS(key: string, bit: number, cb?: Callback<number>): R;
402
403 /**
404 * Remove and get the first element in a list, or block until one is available.
405 */
406 blpop: OverloadedLastCommand<string, number, [string, string], R>;
407 BLPOP: OverloadedLastCommand<string, number, [string, string], R>;
408
409 /**
410 * Remove and get the last element in a list, or block until one is available.
411 */
412 brpop: OverloadedLastCommand<string, number, [string, string], R>;
413 BRPOP: OverloadedLastCommand<string, number, [string, string], R>;
414
415 /**
416 * Pop a value from a list, push it to another list and return it; or block until one is available.
417 */
418 brpoplpush(source: string, destination: string, timeout: number, cb?: Callback<string | null>): R;
419 BRPOPLPUSH(source: string, destination: string, timeout: number, cb?: Callback<string | null>): R;
420
421 /**
422 * ADDSLOTS - Assign new hash slots to receiving node.
423 * COUNT-FAILURE-REPORTS - Return the number of failure reports active for a given node.
424 * COUNTKEYSINSLOT - Return the number of local keys in the specified hash slot.
425 * DELSLOTS - Set hash slots as unbound in receiving node.
426 * FAILOVER - Forces a slave to perform a manual failover of its master.
427 * FORGET - Remove a node from the nodes table.
428 * GETKEYSINSLOT - Return local key names in the specified hash slot.
429 * INFO - Provides info about Redis Cluster node state.
430 * KEYSLOT - Returns the hash slot of the specified key.
431 * MEET - Force a node cluster to handshake with another node.
432 * NODES - Get cluster config for the node.
433 * REPLICATE - Reconfigure a node as a slave of the specified master node.
434 * RESET - Reset a Redis Cluster node.
435 * SAVECONFIG - Forces the node to save cluster state on disk.
436 * SET-CONFIG-EPOCH - Set the configuration epoch in a new node.
437 * SETSLOT - Bind a hash slot to a specified node.
438 * SLAVES - List slave nodes of the specified master node.
439 * SLOTS - Get array of Cluster slot to node mappings.
440 */
441 cluster: OverloadedCommand<string, any, this>;
442 CLUSTER: OverloadedCommand<string, any, this>;
443
444 /**
445 * Get array of Redis command details.
446 *
447 * COUNT - Get total number of Redis commands.
448 * GETKEYS - Extract keys given a full Redis command.
449 * INFO - Get array of specific REdis command details.
450 */
451 command(cb?: Callback<Array<[string, number, string[], number, number, number]>>): R;
452 COMMAND(cb?: Callback<Array<[string, number, string[], number, number, number]>>): R;
453
454 /**
455 * Get array of Redis command details.
456 *
457 * COUNT - Get array of Redis command details.
458 * GETKEYS - Extract keys given a full Redis command.
459 * INFO - Get array of specific Redis command details.
460 * GET - Get the value of a configuration parameter.
461 * REWRITE - Rewrite the configuration file with the in memory configuration.
462 * SET - Set a configuration parameter to the given value.
463 * RESETSTAT - Reset the stats returned by INFO.
464 */
465 config: OverloadedCommand<string, boolean, R>;
466 CONFIG: OverloadedCommand<string, boolean, R>;
467
468 /**
469 * Return the number of keys in the selected database.
470 */
471 dbsize(cb?: Callback<number>): R;
472 DBSIZE(cb?: Callback<number>): R;
473
474 /**
475 * OBJECT - Get debugging information about a key.
476 * SEGFAULT - Make the server crash.
477 */
478 debug: OverloadedCommand<string, boolean, R>;
479 DEBUG: OverloadedCommand<string, boolean, R>;
480
481 /**
482 * Decrement the integer value of a key by one.
483 */
484 decr(key: string, cb?: Callback<number>): R;
485 DECR(key: string, cb?: Callback<number>): R;
486
487 /**
488 * Decrement the integer value of a key by the given number.
489 */
490 decrby(key: string, decrement: number, cb?: Callback<number>): R;
491 DECRBY(key: string, decrement: number, cb?: Callback<number>): R;
492
493 /**
494 * Delete a key.
495 */
496 del: OverloadedCommand<string, number, R>;
497 DEL: OverloadedCommand<string, number, R>;
498
499 /**
500 * Discard all commands issued after MULTI.
501 */
502 discard(cb?: Callback<'OK'>): R;
503 DISCARD(cb?: Callback<'OK'>): R;
504
505 /**
506 * Return a serialized version of the value stored at the specified key.
507 */
508 dump(key: string, cb?: Callback<string>): R;
509 DUMP(key: string, cb?: Callback<string>): R;
510
511 /**
512 * Echo the given string.
513 */
514 echo<T extends string>(message: T, cb?: Callback<T>): R;
515 ECHO<T extends string>(message: T, cb?: Callback<T>): R;
516
517 /**
518 * Execute a Lua script server side.
519 */
520 eval: OverloadedCommand<string | number, any, R>;
521 EVAL: OverloadedCommand<string | number, any, R>;
522
523 /**
524 * Execute a Lue script server side.
525 */
526 evalsha: OverloadedCommand<string | number, any, R>;
527 EVALSHA: OverloadedCommand<string | number, any, R>;
528
529 /**
530 * Determine if a key exists.
531 */
532 exists: OverloadedCommand<string, number, R>;
533 EXISTS: OverloadedCommand<string, number, R>;
534
535 /**
536 * Set a key's time to live in seconds.
537 */
538 expire(key: string, seconds: number, cb?: Callback<number>): R;
539 EXPIRE(key: string, seconds: number, cb?: Callback<number>): R;
540
541 /**
542 * Set the expiration for a key as a UNIX timestamp.
543 */
544 expireat(key: string, timestamp: number, cb?: Callback<number>): R;
545 EXPIREAT(key: string, timestamp: number, cb?: Callback<number>): R;
546
547 /**
548 * Remove all keys from all databases.
549 */
550 flushall(cb?: Callback<string>): R;
551 flushall(async: "ASYNC", cb?: Callback<string>): R;
552 FLUSHALL(cb?: Callback<string>): R;
553 FLUSHALL(async: 'ASYNC', cb?: Callback<string>): R;
554
555 /**
556 * Remove all keys from the current database.
557 */
558 flushdb(cb?: Callback<'OK'>): R;
559 flushdb(async: "ASYNC", cb?: Callback<string>): R;
560 FLUSHDB(cb?: Callback<'OK'>): R;
561 FLUSHDB(async: 'ASYNC', cb?: Callback<string>): R;
562
563 /**
564 * Add one or more geospatial items in the geospatial index represented using a sorted set.
565 */
566 geoadd: OverloadedKeyCommand<string | number, number, R>;
567 GEOADD: OverloadedKeyCommand<string | number, number, R>;
568
569 /**
570 * Returns members of a geospatial index as standard geohash strings.
571 */
572 geohash: OverloadedKeyCommand<string, string, R>;
573 GEOHASH: OverloadedKeyCommand<string, string, R>;
574
575 /**
576 * Returns longitude and latitude of members of a geospatial index.
577 */
578 geopos: OverloadedKeyCommand<string, Array<[number, number]>, R>;
579 GEOPOS: OverloadedKeyCommand<string, Array<[number, number]>, R>;
580
581 /**
582 * Returns the distance between two members of a geospatial index.
583 */
584 geodist: OverloadedKeyCommand<string, string, R>;
585 GEODIST: OverloadedKeyCommand<string, string, R>;
586
587 /**
588 * Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point.
589 */
590 georadius: OverloadedKeyCommand<string | number, Array<string | [string, string | [string, string]]>, R>;
591 GEORADIUS: OverloadedKeyCommand<string | number, Array<string | [string, string | [string, string]]>, R>;
592
593 /**
594 * Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member.
595 */
596 georadiusbymember: OverloadedKeyCommand<string | number, Array<string | [string, string | [string, string]]>, R>;
597 GEORADIUSBYMEMBER: OverloadedKeyCommand<string | number, Array<string | [string, string | [string, string]]>, R>;
598
599 /**
600 * Get the value of a key.
601 */
602 get(key: string, cb?: Callback<string | null>): R;
603 GET(key: string, cb?: Callback<string | null>): R;
604
605 /**
606 * Returns the bit value at offset in the string value stored at key.
607 */
608 getbit(key: string, offset: number, cb?: Callback<number>): R;
609 GETBIT(key: string, offset: number, cb?: Callback<number>): R;
610
611 /**
612 * Get a substring of the string stored at a key.
613 */
614 getrange(key: string, start: number, end: number, cb?: Callback<string>): R;
615 GETRANGE(key: string, start: number, end: number, cb?: Callback<string>): R;
616
617 /**
618 * Set the string value of a key and return its old value.
619 */
620 getset(key: string, value: string, cb?: Callback<string>): R;
621 GETSET(key: string, value: string, cb?: Callback<string>): R;
622
623 /**
624 * Delete on or more hash fields.
625 */
626 hdel: OverloadedKeyCommand<string, number, R>;
627 HDEL: OverloadedKeyCommand<string, number, R>;
628
629 /**
630 * Determine if a hash field exists.
631 */
632 hexists(key: string, field: string, cb?: Callback<number>): R;
633 HEXISTS(key: string, field: string, cb?: Callback<number>): R;
634
635 /**
636 * Get the value of a hash field.
637 */
638 hget(key: string, field: string, cb?: Callback<string>): R;
639 HGET(key: string, field: string, cb?: Callback<string>): R;
640
641 /**
642 * Get all fields and values in a hash.
643 */
644 hgetall(key: string, cb?: Callback<{ [key: string]: string }>): R;
645 HGETALL(key: string, cb?: Callback<{ [key: string]: string }>): R;
646
647 /**
648 * Increment the integer value of a hash field by the given number.
649 */
650 hincrby(key: string, field: string, increment: number, cb?: Callback<number>): R;
651 HINCRBY(key: string, field: string, increment: number, cb?: Callback<number>): R;
652
653 /**
654 * Increment the float value of a hash field by the given amount.
655 */
656 hincrbyfloat(key: string, field: string, increment: number, cb?: Callback<string>): R;
657 HINCRBYFLOAT(key: string, field: string, increment: number, cb?: Callback<string>): R;
658
659 /**
660 * Get all the fields of a hash.
661 */
662 hkeys(key: string, cb?: Callback<string[]>): R;
663 HKEYS(key: string, cb?: Callback<string[]>): R;
664
665 /**
666 * Get the number of fields in a hash.
667 */
668 hlen(key: string, cb?: Callback<number>): R;
669 HLEN(key: string, cb?: Callback<number>): R;
670
671 /**
672 * Get the values of all the given hash fields.
673 */
674 hmget: OverloadedKeyCommand<string, string[], R>;
675 HMGET: OverloadedKeyCommand<string, string[], R>;
676
677 /**
678 * Set the string value of a hash field.
679 */
680 hset: OverloadedSetCommand<string, number, R>;
681 HSET: OverloadedSetCommand<string, number, R>;
682
683 /**
684 * Set the value of a hash field, only if the field does not exist.
685 */
686 hsetnx(key: string, field: string, value: string, cb?: Callback<number>): R;
687 HSETNX(key: string, field: string, value: string, cb?: Callback<number>): R;
688
689 /**
690 * Get the length of the value of a hash field.
691 */
692 hstrlen(key: string, field: string, cb?: Callback<number>): R;
693 HSTRLEN(key: string, field: string, cb?: Callback<number>): R;
694
695 /**
696 * Get all the values of a hash.
697 */
698 hvals(key: string, cb?: Callback<string[]>): R;
699 HVALS(key: string, cb?: Callback<string[]>): R;
700
701 /**
702 * Increment the integer value of a key by one.
703 */
704 incr(key: string, cb?: Callback<number>): R;
705 INCR(key: string, cb?: Callback<number>): R;
706
707 /**
708 * Increment the integer value of a key by the given amount.
709 */
710 incrby(key: string, increment: number, cb?: Callback<number>): R;
711 INCRBY(key: string, increment: number, cb?: Callback<number>): R;
712
713 /**
714 * Increment the float value of a key by the given amount.
715 */
716 incrbyfloat(key: string, increment: number, cb?: Callback<string>): R;
717 INCRBYFLOAT(key: string, increment: number, cb?: Callback<string>): R;
718
719 /**
720 * Find all keys matching the given pattern.
721 */
722 keys(pattern: string, cb?: Callback<string[]>): R;
723 KEYS(pattern: string, cb?: Callback<string[]>): R;
724
725 /**
726 * Get the UNIX time stamp of the last successful save to disk.
727 */
728 lastsave(cb?: Callback<number>): R;
729 LASTSAVE(cb?: Callback<number>): R;
730
731 /**
732 * Get an element from a list by its index.
733 */
734 lindex(key: string, index: number, cb?: Callback<string>): R;
735 LINDEX(key: string, index: number, cb?: Callback<string>): R;
736
737 /**
738 * Insert an element before or after another element in a list.
739 */
740 linsert(key: string, dir: 'BEFORE' | 'AFTER', pivot: string, value: string, cb?: Callback<string>): R;
741 LINSERT(key: string, dir: 'BEFORE' | 'AFTER', pivot: string, value: string, cb?: Callback<string>): R;
742
743 /**
744 * Get the length of a list.
745 */
746 llen(key: string, cb?: Callback<number>): R;
747 LLEN(key: string, cb?: Callback<number>): R;
748
749 /**
750 * Remove and get the first element in a list.
751 */
752 lpop(key: string, cb?: Callback<string>): R;
753 LPOP(key: string, cb?: Callback<string>): R;
754
755 /**
756 * Prepend one or multiple values to a list.
757 */
758 lpush: OverloadedKeyCommand<string, number, R>;
759 LPUSH: OverloadedKeyCommand<string, number, R>;
760
761 /**
762 * Prepend a value to a list, only if the list exists.
763 */
764 lpushx(key: string, value: string, cb?: Callback<number>): R;
765 LPUSHX(key: string, value: string, cb?: Callback<number>): R;
766
767 /**
768 * Get a range of elements from a list.
769 */
770 lrange(key: string, start: number, stop: number, cb?: Callback<string[]>): R;
771 LRANGE(key: string, start: number, stop: number, cb?: Callback<string[]>): R;
772
773 /**
774 * Remove elements from a list.
775 */
776 lrem(key: string, count: number, value: string, cb?: Callback<number>): R;
777 LREM(key: string, count: number, value: string, cb?: Callback<number>): R;
778
779 /**
780 * Set the value of an element in a list by its index.
781 */
782 lset(key: string, index: number, value: string, cb?: Callback<'OK'>): R;
783 LSET(key: string, index: number, value: string, cb?: Callback<'OK'>): R;
784
785 /**
786 * Trim a list to the specified range.
787 */
788 ltrim(key: string, start: number, stop: number, cb?: Callback<'OK'>): R;
789 LTRIM(key: string, start: number, stop: number, cb?: Callback<'OK'>): R;
790
791 /**
792 * Get the values of all given keys.
793 */
794 mget: OverloadedCommand<string, string[], R>;
795 MGET: OverloadedCommand<string, string[], R>;
796
797 /**
798 * Atomically tranfer a key from a Redis instance to another one.
799 */
800 migrate: OverloadedCommand<string, boolean, R>;
801 MIGRATE: OverloadedCommand<string, boolean, R>;
802
803 /**
804 * Move a key to another database.
805 */
806 move(key: string, db: string | number): R;
807 MOVE(key: string, db: string | number): R;
808
809 /**
810 * Set multiple keys to multiple values.
811 */
812 mset: OverloadedCommand<string, boolean, R>;
813 MSET: OverloadedCommand<string, boolean, R>;
814
815 /**
816 * Set multiple keys to multiple values, only if none of the keys exist.
817 */
818 msetnx: OverloadedCommand<string, boolean, R>;
819 MSETNX: OverloadedCommand<string, boolean, R>;
820
821 /**
822 * Inspect the internals of Redis objects.
823 */
824 object: OverloadedCommand<string, any, R>;
825 OBJECT: OverloadedCommand<string, any, R>;
826
827 /**
828 * Remove the expiration from a key.
829 */
830 persist(key: string, cb?: Callback<number>): R;
831 PERSIST(key: string, cb?: Callback<number>): R;
832
833 /**
834 * Remove a key's time to live in milliseconds.
835 */
836 pexpire(key: string, milliseconds: number, cb?: Callback<number>): R;
837 PEXPIRE(key: string, milliseconds: number, cb?: Callback<number>): R;
838
839 /**
840 * Set the expiration for a key as a UNIX timestamp specified in milliseconds.
841 */
842 pexpireat(key: string, millisecondsTimestamp: number, cb?: Callback<number>): R;
843 PEXPIREAT(key: string, millisecondsTimestamp: number, cb?: Callback<number>): R;
844
845 /**
846 * Adds the specified elements to the specified HyperLogLog.
847 */
848 pfadd: OverloadedKeyCommand<string, number, R>;
849 PFADD: OverloadedKeyCommand<string, number, R>;
850
851 /**
852 * Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s).
853 */
854 pfcount: OverloadedCommand<string, number, R>;
855 PFCOUNT: OverloadedCommand<string, number, R>;
856
857 /**
858 * Merge N different HyperLogLogs into a single one.
859 */
860 pfmerge: OverloadedCommand<string, boolean, R>;
861 PFMERGE: OverloadedCommand<string, boolean, R>;
862
863 /**
864 * Set the value and expiration in milliseconds of a key.
865 */
866 psetex(key: string, milliseconds: number, value: string, cb?: Callback<'OK'>): R;
867 PSETEX(key: string, milliseconds: number, value: string, cb?: Callback<'OK'>): R;
868
869 /**
870 * Inspect the state of the Pub/Sub subsytem.
871 */
872 pubsub: OverloadedCommand<string, number, R>;
873 PUBSUB: OverloadedCommand<string, number, R>;
874
875 /**
876 * Get the time to live for a key in milliseconds.
877 */
878 pttl(key: string, cb?: Callback<number>): R;
879 PTTL(key: string, cb?: Callback<number>): R;
880
881 /**
882 * Close the connection.
883 */
884 quit(cb?: Callback<'OK'>): R;
885 QUIT(cb?: Callback<'OK'>): R;
886
887 /**
888 * Return a random key from the keyspace.
889 */
890 randomkey(cb?: Callback<string>): R;
891 RANDOMKEY(cb?: Callback<string>): R;
892
893 /**
894 * Enables read queries for a connection to a cluster slave node.
895 */
896 readonly(cb?: Callback<string>): R;
897 READONLY(cb?: Callback<string>): R;
898
899 /**
900 * Disables read queries for a connection to cluster slave node.
901 */
902 readwrite(cb?: Callback<string>): R;
903 READWRITE(cb?: Callback<string>): R;
904
905 /**
906 * Rename a key.
907 */
908 rename(key: string, newkey: string, cb?: Callback<'OK'>): R;
909 RENAME(key: string, newkey: string, cb?: Callback<'OK'>): R;
910
911 /**
912 * Rename a key, only if the new key does not exist.
913 */
914 renamenx(key: string, newkey: string, cb?: Callback<number>): R;
915 RENAMENX(key: string, newkey: string, cb?: Callback<number>): R;
916
917 /**
918 * Create a key using the provided serialized value, previously obtained using DUMP.
919 */
920 restore(key: string, ttl: number, serializedValue: string, cb?: Callback<'OK'>): R;
921 RESTORE(key: string, ttl: number, serializedValue: string, cb?: Callback<'OK'>): R;
922
923 /**
924 * Return the role of the instance in the context of replication.
925 */
926 role(cb?: Callback<[string, number, Array<[string, string, string]>]>): R;
927 ROLE(cb?: Callback<[string, number, Array<[string, string, string]>]>): R;
928
929 /**
930 * Remove and get the last element in a list.
931 */
932 rpop(key: string, cb?: Callback<string>): R;
933 RPOP(key: string, cb?: Callback<string>): R;
934
935 /**
936 * Remove the last element in a list, prepend it to another list and return it.
937 */
938 rpoplpush(source: string, destination: string, cb?: Callback<string>): R;
939 RPOPLPUSH(source: string, destination: string, cb?: Callback<string>): R;
940
941 /**
942 * Append one or multiple values to a list.
943 */
944 rpush: OverloadedKeyCommand<string, number, R>;
945 RPUSH: OverloadedKeyCommand<string, number, R>;
946
947 /**
948 * Append a value to a list, only if the list exists.
949 */
950 rpushx(key: string, value: string, cb?: Callback<number>): R;
951 RPUSHX(key: string, value: string, cb?: Callback<number>): R;
952
953 /**
954 * Append one or multiple members to a set.
955 */
956 sadd: OverloadedKeyCommand<string, number, R>;
957 SADD: OverloadedKeyCommand<string, number, R>;
958
959 /**
960 * Synchronously save the dataset to disk.
961 */
962 save(cb?: Callback<string>): R;
963 SAVE(cb?: Callback<string>): R;
964
965 /**
966 * Get the number of members in a set.
967 */
968 scard(key: string, cb?: Callback<number>): R;
969 SCARD(key: string, cb?: Callback<number>): R;
970
971 /**
972 * DEBUG - Set the debug mode for executed scripts.
973 * EXISTS - Check existence of scripts in the script cache.
974 * FLUSH - Remove all scripts from the script cache.
975 * KILL - Kill the script currently in execution.
976 * LOAD - Load the specified Lua script into the script cache.
977 */
978 script: OverloadedCommand<string, any, R>;
979 SCRIPT: OverloadedCommand<string, any, R>;
980
981 /**
982 * Subtract multiple sets.
983 */
984 sdiff: OverloadedCommand<string, string[], R>;
985 SDIFF: OverloadedCommand<string, string[], R>;
986
987 /**
988 * Subtract multiple sets and store the resulting set in a key.
989 */
990 sdiffstore: OverloadedKeyCommand<string, number, R>;
991 SDIFFSTORE: OverloadedKeyCommand<string, number, R>;
992
993 /**
994 * Change the selected database for the current connection.
995 */
996 select(index: number | string, cb?: Callback<string>): R;
997 SELECT(index: number | string, cb?: Callback<string>): R;
998
999 /**
1000 * Set the string value of a key.
1001 */
1002 set(key: string, value: string, cb?: Callback<'OK'>): R;
1003 set(key: string, value: string, flag: string, cb?: Callback<'OK'>): R;
1004 set(key: string, value: string, mode: string, duration: number, cb?: Callback<'OK' | undefined>): R;
1005 set(key: string, value: string, mode: string, duration: number, flag: string, cb?: Callback<'OK' | undefined>): R;
1006 set(key: string, value: string, flag: string, mode: string, duration: number, cb?: Callback<'OK' | undefined>): R;
1007 SET(key: string, value: string, cb?: Callback<'OK'>): R;
1008 SET(key: string, value: string, flag: string, cb?: Callback<'OK'>): R;
1009 SET(key: string, value: string, mode: string, duration: number, cb?: Callback<'OK' | undefined>): R;
1010 SET(key: string, value: string, mode: string, duration: number, flag: string, cb?: Callback<'OK' | undefined>): R;
1011 SET(key: string, value: string, flag: string, mode: string, duration: number, cb?: Callback<'OK' | undefined>): R;
1012
1013 /**
1014 * Sets or clears the bit at offset in the string value stored at key.
1015 */
1016 setbit(key: string, offset: number, value: string, cb?: Callback<number>): R;
1017 SETBIT(key: string, offset: number, value: string, cb?: Callback<number>): R;
1018
1019 /**
1020 * Set the value and expiration of a key.
1021 */
1022 setex(key: string, seconds: number, value: string, cb?: Callback<string>): R;
1023 SETEX(key: string, seconds: number, value: string, cb?: Callback<string>): R;
1024
1025 /**
1026 * Set the value of a key, only if the key does not exist.
1027 */
1028 setnx(key: string, value: string, cb?: Callback<number>): R;
1029 SETNX(key: string, value: string, cb?: Callback<number>): R;
1030
1031 /**
1032 * Overwrite part of a string at key starting at the specified offset.
1033 */
1034 setrange(key: string, offset: number, value: string, cb?: Callback<number>): R;
1035 SETRANGE(key: string, offset: number, value: string, cb?: Callback<number>): R;
1036
1037 /**
1038 * Synchronously save the dataset to disk and then shut down the server.
1039 */
1040 shutdown: OverloadedCommand<string, string, R>;
1041 SHUTDOWN: OverloadedCommand<string, string, R>;
1042
1043 /**
1044 * Intersect multiple sets.
1045 */
1046 sinter: OverloadedKeyCommand<string, string[], R>;
1047 SINTER: OverloadedKeyCommand<string, string[], R>;
1048
1049 /**
1050 * Intersect multiple sets and store the resulting set in a key.
1051 */
1052 sinterstore: OverloadedCommand<string, number, R>;
1053 SINTERSTORE: OverloadedCommand<string, number, R>;
1054
1055 /**
1056 * Determine if a given value is a member of a set.
1057 */
1058 sismember(key: string, member: string, cb?: Callback<number>): R;
1059 SISMEMBER(key: string, member: string, cb?: Callback<number>): R;
1060
1061 /**
1062 * Make the server a slave of another instance, or promote it as master.
1063 */
1064 slaveof(host: string, port: string | number, cb?: Callback<string>): R;
1065 SLAVEOF(host: string, port: string | number, cb?: Callback<string>): R;
1066
1067 /**
1068 * Manages the Redis slow queries log.
1069 */
1070 slowlog: OverloadedCommand<string, Array<[number, number, number, string[]]>, R>;
1071 SLOWLOG: OverloadedCommand<string, Array<[number, number, number, string[]]>, R>;
1072
1073 /**
1074 * Get all the members in a set.
1075 */
1076 smembers(key: string, cb?: Callback<string[]>): R;
1077 SMEMBERS(key: string, cb?: Callback<string[]>): R;
1078
1079 /**
1080 * Move a member from one set to another.
1081 */
1082 smove(source: string, destination: string, member: string, cb?: Callback<number>): R;
1083 SMOVE(source: string, destination: string, member: string, cb?: Callback<number>): R;
1084
1085 /**
1086 * Sort the elements in a list, set or sorted set.
1087 */
1088 sort: OverloadedCommand<string, string[], R>;
1089 SORT: OverloadedCommand<string, string[], R>;
1090
1091 /**
1092 * Remove and return one or multiple random members from a set.
1093 */
1094 spop(key: string, cb?: Callback<string>): R;
1095 spop(key: string, count: number, cb?: Callback<string[]>): R;
1096 SPOP(key: string, cb?: Callback<string>): R;
1097 SPOP(key: string, count: number, cb?: Callback<string[]>): R;
1098
1099 /**
1100 * Get one or multiple random members from a set.
1101 */
1102 srandmember(key: string, cb?: Callback<string>): R;
1103 srandmember(key: string, count: number, cb?: Callback<string[]>): R;
1104 SRANDMEMBER(key: string, cb?: Callback<string>): R;
1105 SRANDMEMBER(key: string, count: number, cb?: Callback<string[]>): R;
1106
1107 /**
1108 * Remove one or more members from a set.
1109 */
1110 srem: OverloadedKeyCommand<string, number, R>;
1111 SREM: OverloadedKeyCommand<string, number, R>;
1112
1113 /**
1114 * Get the length of the value stored in a key.
1115 */
1116 strlen(key: string, cb?: Callback<number>): R;
1117 STRLEN(key: string, cb?: Callback<number>): R;
1118
1119 /**
1120 * Add multiple sets.
1121 */
1122 sunion: OverloadedCommand<string, string[], R>;
1123 SUNION: OverloadedCommand<string, string[], R>;
1124
1125 /**
1126 * Add multiple sets and store the resulting set in a key.
1127 */
1128 sunionstore: OverloadedCommand<string, number, R>;
1129 SUNIONSTORE: OverloadedCommand<string, number, R>;
1130
1131 /**
1132 * Internal command used for replication.
1133 */
1134 sync(cb?: Callback<undefined>): R;
1135 SYNC(cb?: Callback<undefined>): R;
1136
1137 /**
1138 * Return the current server time.
1139 */
1140 time(cb?: Callback<[string, string]>): R;
1141 TIME(cb?: Callback<[string, string]>): R;
1142
1143 /**
1144 * Get the time to live for a key.
1145 */
1146 ttl(key: string, cb?: Callback<number>): R;
1147 TTL(key: string, cb?: Callback<number>): R;
1148
1149 /**
1150 * Determine the type stored at key.
1151 */
1152 type(key: string, cb?: Callback<string>): R;
1153 TYPE(key: string, cb?: Callback<string>): R;
1154
1155 /**
1156 * Deletes a key in a non-blocking manner.
1157 * Very similar to DEL, but actual memory reclamation
1158 * happens in a different thread, making this non-blocking.
1159 */
1160 unlink: OverloadedCommand<string, number, R>;
1161 UNLINK: OverloadedCommand<string, number, R>;
1162
1163 /**
1164 * Forget about all watched keys.
1165 */
1166 unwatch(cb?: Callback<'OK'>): R;
1167 UNWATCH(cb?: Callback<'OK'>): R;
1168
1169 /**
1170 * Wait for the synchronous replication of all the write commands sent in the context of the current connection.
1171 */
1172 wait(numslaves: number, timeout: number, cb?: Callback<number>): R;
1173 WAIT(numslaves: number, timeout: number, cb?: Callback<number>): R;
1174
1175 /**
1176 * Watch the given keys to determine execution of the MULTI/EXEC block.
1177 */
1178 watch: OverloadedCommand<string, 'OK', R>;
1179 WATCH: OverloadedCommand<string, 'OK', R>;
1180
1181 /**
1182 * Add one or more members to a sorted set, or update its score if it already exists.
1183 */
1184 zadd: OverloadedKeyCommand<string | number, number, R>;
1185 ZADD: OverloadedKeyCommand<string | number, number, R>;
1186
1187 /**
1188 * Get the number of members in a sorted set.
1189 */
1190 zcard(key: string, cb?: Callback<number>): R;
1191 ZCARD(key: string, cb?: Callback<number>): R;
1192
1193 /**
1194 * Count the members in a sorted set with scores between the given values.
1195 */
1196 zcount(key: string, min: number | string, max: number | string, cb?: Callback<number>): R;
1197 ZCOUNT(key: string, min: number | string, max: number | string, cb?: Callback<number>): R;
1198
1199 /**
1200 * Increment the score of a member in a sorted set.
1201 */
1202 zincrby(key: string, increment: number, member: string, cb?: Callback<string>): R;
1203 ZINCRBY(key: string, increment: number, member: string, cb?: Callback<string>): R;
1204
1205 /**
1206 * Intersect multiple sorted sets and store the resulting sorted set in a new key.
1207 */
1208 zinterstore: OverloadedCommand<string | number, number, R>;
1209 ZINTERSTORE: OverloadedCommand<string | number, number, R>;
1210
1211 /**
1212 * Count the number of members in a sorted set between a given lexicographic range.
1213 */
1214 zlexcount(key: string, min: string, max: string, cb?: Callback<number>): R;
1215 ZLEXCOUNT(key: string, min: string, max: string, cb?: Callback<number>): R;
1216
1217 /**
1218 * Return a range of members in a sorted set, by index.
1219 */
1220 zrange(key: string, start: number, stop: number, cb?: Callback<string[]>): R;
1221 zrange(key: string, start: number, stop: number, withscores: string, cb?: Callback<string[]>): R;
1222 ZRANGE(key: string, start: number, stop: number, cb?: Callback<string[]>): R;
1223 ZRANGE(key: string, start: number, stop: number, withscores: string, cb?: Callback<string[]>): R;
1224
1225 /**
1226 * Return a range of members in a sorted set, by lexicographical range.
1227 */
1228 zrangebylex(key: string, min: string, max: string, cb?: Callback<string[]>): R;
1229 zrangebylex(key: string, min: string, max: string, limit: string, offset: number, count: number, cb?: Callback<string[]>): R;
1230 ZRANGEBYLEX(key: string, min: string, max: string, cb?: Callback<string[]>): R;
1231 ZRANGEBYLEX(key: string, min: string, max: string, limit: string, offset: number, count: number, cb?: Callback<string[]>): R;
1232
1233 /**
1234 * Return a range of members in a sorted set, by lexicographical range, ordered from higher to lower strings.
1235 */
1236 zrevrangebylex(key: string, min: string, max: string, cb?: Callback<string[]>): R;
1237 zrevrangebylex(key: string, min: string, max: string, limit: string, offset: number, count: number, cb?: Callback<string[]>): R;
1238 ZREVRANGEBYLEX(key: string, min: string, max: string, cb?: Callback<string[]>): R;
1239 ZREVRANGEBYLEX(key: string, min: string, max: string, limit: string, offset: number, count: number, cb?: Callback<string[]>): R;
1240
1241 /**
1242 * Return a range of members in a sorted set, by score.
1243 */
1244 zrangebyscore(key: string, min: number | string, max: number | string, cb?: Callback<string[]>): R;
1245 zrangebyscore(key: string, min: number | string, max: number | string, withscores: string, cb?: Callback<string[]>): R;
1246 zrangebyscore(key: string, min: number | string, max: number | string, limit: string, offset: number, count: number, cb?: Callback<string[]>): R;
1247 zrangebyscore(key: string, min: number | string, max: number | string, withscores: string, limit: string, offset: number, count: number, cb?: Callback<string[]>): R;
1248 ZRANGEBYSCORE(key: string, min: number | string, max: number | string, cb?: Callback<string[]>): R;
1249 ZRANGEBYSCORE(key: string, min: number | string, max: number | string, withscores: string, cb?: Callback<string[]>): R;
1250 ZRANGEBYSCORE(key: string, min: number | string, max: number | string, limit: string, offset: number, count: number, cb?: Callback<string[]>): R;
1251 ZRANGEBYSCORE(key: string, min: number | string, max: number | string, withscores: string, limit: string, offset: number, count: number, cb?: Callback<string[]>): R;
1252
1253 /**
1254 * Determine the index of a member in a sorted set.
1255 */
1256 zrank(key: string, member: string, cb?: Callback<number | null>): R;
1257 ZRANK(key: string, member: string, cb?: Callback<number | null>): R;
1258
1259 /**
1260 * Remove one or more members from a sorted set.
1261 */
1262 zrem: OverloadedKeyCommand<string, number, R>;
1263 ZREM: OverloadedKeyCommand<string, number, R>;
1264
1265 /**
1266 * Remove all members in a sorted set between the given lexicographical range.
1267 */
1268 zremrangebylex(key: string, min: string, max: string, cb?: Callback<number>): R;
1269 ZREMRANGEBYLEX(key: string, min: string, max: string, cb?: Callback<number>): R;
1270
1271 /**
1272 * Remove all members in a sorted set within the given indexes.
1273 */
1274 zremrangebyrank(key: string, start: number, stop: number, cb?: Callback<number>): R;
1275 ZREMRANGEBYRANK(key: string, start: number, stop: number, cb?: Callback<number>): R;
1276
1277 /**
1278 * Remove all members in a sorted set within the given indexes.
1279 */
1280 zremrangebyscore(key: string, min: string | number, max: string | number, cb?: Callback<number>): R;
1281 ZREMRANGEBYSCORE(key: string, min: string | number, max: string | number, cb?: Callback<number>): R;
1282
1283 /**
1284 * Return a range of members in a sorted set, by index, with scores ordered from high to low.
1285 */
1286 zrevrange(key: string, start: number, stop: number, cb?: Callback<string[]>): R;
1287 zrevrange(key: string, start: number, stop: number, withscores: string, cb?: Callback<string[]>): R;
1288 ZREVRANGE(key: string, start: number, stop: number, cb?: Callback<string[]>): R;
1289 ZREVRANGE(key: string, start: number, stop: number, withscores: string, cb?: Callback<string[]>): R;
1290
1291 /**
1292 * Return a range of members in a sorted set, by score, with scores ordered from high to low.
1293 */
1294 zrevrangebyscore(key: string, min: number | string, max: number | string, cb?: Callback<string[]>): R;
1295 zrevrangebyscore(key: string, min: number | string, max: number | string, withscores: string, cb?: Callback<string[]>): R;
1296 zrevrangebyscore(key: string, min: number | string, max: number | string, limit: string, offset: number, count: number, cb?: Callback<string[]>): R;
1297 zrevrangebyscore(key: string, min: number | string, max: number | string, withscores: string, limit: string, offset: number, count: number, cb?: Callback<string[]>): R;
1298 ZREVRANGEBYSCORE(key: string, min: number | string, max: number | string, cb?: Callback<string[]>): R;
1299 ZREVRANGEBYSCORE(key: string, min: number | string, max: number | string, withscores: string, cb?: Callback<string[]>): R;
1300 ZREVRANGEBYSCORE(key: string, min: number | string, max: number | string, limit: string, offset: number, count: number, cb?: Callback<string[]>): R;
1301 ZREVRANGEBYSCORE(key: string, min: number | string, max: number | string, withscores: string, limit: string, offset: number, count: number, cb?: Callback<string[]>): R;
1302
1303 /**
1304 * Determine the index of a member in a sorted set, with scores ordered from high to low.
1305 */
1306 zrevrank(key: string, member: string, cb?: Callback<number | null>): R;
1307 ZREVRANK(key: string, member: string, cb?: Callback<number | null>): R;
1308
1309 /**
1310 * Get the score associated with the given member in a sorted set.
1311 */
1312 zscore(key: string, member: string, cb?: Callback<string>): R;
1313 ZSCORE(key: string, member: string, cb?: Callback<string>): R;
1314
1315 /**
1316 * Add multiple sorted sets and store the resulting sorted set in a new key.
1317 */
1318 zunionstore: OverloadedCommand<string | number, number, R>;
1319 ZUNIONSTORE: OverloadedCommand<string | number, number, R>;
1320
1321 /**
1322 * Incrementally iterate the keys space.
1323 */
1324 scan: OverloadedCommand<string, [string, string[]], R>;
1325 SCAN: OverloadedCommand<string, [string, string[]], R>;
1326
1327 /**
1328 * Incrementally iterate Set elements.
1329 */
1330 sscan: OverloadedKeyCommand<string, [string, string[]], R>;
1331 SSCAN: OverloadedKeyCommand<string, [string, string[]], R>;
1332
1333 /**
1334 * Incrementally iterate hash fields and associated values.
1335 */
1336 hscan: OverloadedKeyCommand<string, [string, string[]], R>;
1337 HSCAN: OverloadedKeyCommand<string, [string, string[]], R>;
1338
1339 /**
1340 * Incrementally iterate sorted sets elements and associated scores.
1341 */
1342 zscan: OverloadedKeyCommand<string, [string, string[]], R>;
1343 ZSCAN: OverloadedKeyCommand<string, [string, string[]], R>;
1344}
1345
1346export const RedisClient: new (options: ClientOpts) => RedisClient;
1347
1348export interface RedisClient extends Commands<boolean>, EventEmitter {
1349 connected: boolean;
1350 command_queue_length: number;
1351 offline_queue_length: number;
1352 retry_delay: number | Error;
1353 retry_backoff: number;
1354 command_queue: any[];
1355 offline_queue: any[];
1356 connection_id: number;
1357 server_info: ServerInfo;
1358 stream: Duplex;
1359
1360 on(event: 'message' | 'message_buffer', listener: (channel: string, message: string) => void): this;
1361 on(event: 'pmessage' | 'pmessage_buffer', listener: (pattern: string, channel: string, message: string) => void): this;
1362 on(event: 'subscribe' | 'unsubscribe', listener: (channel: string, count: number) => void): this;
1363 on(event: 'psubscribe' | 'punsubscribe', listener: (pattern: string, count: number) => void): this;
1364 on(event: string, listener: (...args: any[]) => void): this;
1365
1366 /**
1367 * Client methods.
1368 */
1369
1370 end(flush?: boolean): void;
1371 unref(): void;
1372
1373 cork(): void;
1374 uncork(): void;
1375
1376 duplicate(options?: ClientOpts, cb?: Callback<RedisClient>): RedisClient;
1377
1378 sendCommand(command: string, cb?: Callback<any>): boolean;
1379 sendCommand(command: string, args?: any[], cb?: Callback<any>): boolean;
1380 send_command(command: string, cb?: Callback<any>): boolean;
1381 send_command(command: string, args?: any[], cb?: Callback<any>): boolean;
1382
1383 /**
1384 * Mark the start of a transaction block.
1385 */
1386 multi(args?: Array<Array<string | number | Callback<any>>>): Multi;
1387 MULTI(args?: Array<Array<string | number | Callback<any>>>): Multi;
1388
1389 batch(args?: Array<Array<string | number | Callback<any>>>): Multi;
1390 BATCH(args?: Array<Array<string | number | Callback<any>>>): Multi;
1391}
1392
1393export const Multi: new () => Multi;
1394
1395export interface Multi extends Commands<Multi> {
1396 exec(cb?: Callback<any[]>): boolean;
1397 EXEC(cb?: Callback<any[]>): boolean;
1398
1399 exec_atomic(cb?: Callback<any[]>): boolean;
1400 EXEC_ATOMIC(cb?: Callback<any[]>): boolean;
1401}
1402
1403export let debug_mode: boolean;
1404
1405export function createClient(port: number, host?: string, options?: ClientOpts): RedisClient;
1406export function createClient(unix_socket: string, options?: ClientOpts): RedisClient;
1407export function createClient(redis_url: string, options?: ClientOpts): RedisClient;
1408export function createClient(options?: ClientOpts): RedisClient;
1409
1410export function addCommand(command: string): void;
1411export function add_command(command: string): void;
1412
1413export function print(err: Error | null, reply: any): void;
1414
1415export class RedisError extends Error {
1416 name: string;
1417}
1418export class ReplyError extends RedisError {
1419 command: string;
1420 args?: unknown[] | undefined;
1421 code: string;
1422}
1423export class AbortError extends RedisError {
1424 command: string;
1425 args?: unknown[] | undefined;
1426 code?: string | undefined;
1427}
1428export class ParserError extends RedisError {
1429 offset: number;
1430 buffer: Buffer;
1431}
1432export class AggregateError extends AbortError { }