// Type definitions for ioredis 4.28 // Project: https://github.com/luin/ioredis // Definitions by: York Yao // Christopher Eck // Yoga Aliarham // Ebrahim // Whemoon Jang // Dmitry Motovilov // Oleg Repin // Ting-Wai To // Alex Petty // Simon Schick // Tianlin // Demian Rodriguez // Andrew Lavers // Claudiu Ceia // Asyrique // Michael Salaverry // Hannes Van De Vreken // T.J. Tarazevits // Michiel De Mey // Dae Heon Han // Yongkyun Choi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 /* =================== USAGE =================== import * as Redis from "ioredis"; const redis = new Redis(); =============================================== */ /// import { ConnectionOptions } from 'tls'; import { Readable } from 'stream'; import { EventEmitter } from 'events'; interface RedisStatic { new (port?: number, host?: string, options?: IORedis.RedisOptions): IORedis.Redis; new (host?: string, options?: IORedis.RedisOptions): IORedis.Redis; new (options?: IORedis.RedisOptions): IORedis.Redis; (port?: number, host?: string, options?: IORedis.RedisOptions): IORedis.Redis; (host?: string, options?: IORedis.RedisOptions): IORedis.Redis; (options?: IORedis.RedisOptions): IORedis.Redis; Cluster: IORedis.ClusterStatic; Command: typeof Command; } declare var IORedis: RedisStatic; export = IORedis; declare class Commander { getBuiltinCommands(): string[]; createBuiltinCommand(commandName: string): {}; defineCommand( name: string, definition: { numberOfKeys?: number | undefined; lua?: string | undefined; }, ): void; sendCommand(): void; } interface CommandOptions { replyEncoding?: string | null | undefined; errorStack?: string | undefined; keyPrefix?: string | undefined; } declare class Command { isCustomCommand: boolean; args: IORedis.ValueType[]; getSlot(): number | null; getKeys(): Array; constructor( name: string, args: IORedis.ValueType[], opts?: CommandOptions, callback?: (err: null, result: any) => void, ); static setArgumentTransformer(name: string, fn: (args: IORedis.ValueType[]) => IORedis.ValueType[]): void; static setReplyTransformer(name: string, fn: (result: any) => any): void; } // For backwards compatibility type _Command = typeof Command; declare namespace IORedis { type BooleanResponse = 1 | 0; type Callback = (err: Error | null, res: T) => void; type KeyType = string | Buffer; type ValueType = string | Buffer | number | any[]; interface OverloadedCommand { (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb: Callback): void; (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, cb: Callback): void; (arg1: T, arg2: T, arg3: T, arg4: T, cb: Callback): void; (arg1: T, arg2: T, arg3: T, cb: Callback): void; (arg1: T, arg2: T, cb: Callback): void; (arg1: T | T[], cb: Callback): void; (cb: Callback): void; (...args: T[]): Promise; (arg1: T[]): Promise; } interface OverloadedListCommand { (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb: Callback): void; (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, cb: Callback): void; (arg1: T, arg2: T, arg3: T, arg4: T, cb: Callback): void; (arg1: T, arg2: T, arg3: T, cb: Callback): void; (arg1: T, arg2: T, cb: Callback): void; (arg1: T | T[], cb: Callback): void; (...args: T[]): Promise; (arg1: T | T[]): Promise; } interface OverloadedBlockingListCommand { (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, timeout: number, cb: Callback): void; (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, timeout: number, cb: Callback): void; (arg1: T, arg2: T, arg3: T, arg4: T, timeout: number, cb: Callback): void; (arg1: T, arg2: T, arg3: T, timeout: number, cb: Callback): void; (arg1: T, arg2: T, timeout: number, cb: Callback): void; (arg1: T, timeout: number, cb: Callback): void; (arg1: Array, cb: Callback): void; (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, timeout: number): Promise; (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, timeout: number): Promise; (arg1: T, arg2: T, arg3: T, arg4: T, timeout: number): Promise; (arg1: T, arg2: T, arg3: T, timeout: number): Promise; (arg1: T, arg2: T, timeout: number): Promise; (arg1: T, timeout: number): Promise; (arg1: Array): Promise; (...args: Array): Promise; } interface OverloadedSubCommand { (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb: Callback): void; (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, cb: Callback): void; (arg1: T, arg2: T, arg3: T, arg4: T, cb: Callback): void; (arg1: T, arg2: T, arg3: T, cb: Callback): void; (arg1: T, arg2: T | T[], cb: Callback): void; (arg1: T | T[], cb: Callback): void; (...args: T[]): Promise; (arg1: T[]): Promise; } interface OverloadedKeyCommand { (key: KeyType, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, arg7: T, arg8: T, cb: Callback): void; (key: KeyType, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, arg7: T, cb: Callback): void; (key: KeyType, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb: Callback): void; (key: KeyType, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, cb: Callback): void; (key: KeyType, arg1: T, arg2: T, arg3: T, arg4: T, cb: Callback): void; (key: KeyType, arg1: T, arg2: T, arg3: T, cb: Callback): void; (key: KeyType, arg1: T, arg2: T, cb: Callback): void; (key: KeyType, arg1: T | T[], cb: Callback): void; (key: KeyType, ...args: T[]): Promise; (key: KeyType, arg1: T[]): Promise; } interface OverloadedHashCommand { (arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb: Callback): void; (arg1: T, arg2: T, arg3: T, arg4: T, cb: Callback): void; (arg1: T, arg2: T, cb: Callback): void; (data: T[] | { [key: string]: T } | Map, cb: Callback): void; (data: T[] | { [key: string]: T } | Map): Promise; (...args: T[]): Promise; } interface OverloadedKeyedHashCommand { (key: KeyType, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb: Callback): void; (key: KeyType, arg1: T, arg2: T, arg3: T, arg4: T, cb: Callback): void; (key: KeyType, arg1: T, arg2: T, cb: Callback): void; (key: KeyType, data: T[] | { [key: string]: T } | Map, cb: Callback): void; (key: KeyType, data: T[] | { [key: string]: T } | Map): Promise; (key: KeyType, ...args: T[]): Promise; } interface OverloadedEvalCommand { (script: string, numKeys: number, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb: Callback): void; (script: string, numKeys: number, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, cb: Callback): void; (script: string, numKeys: number, arg1: T, arg2: T, arg3: T, arg4: T, cb: Callback): void; (script: string, numKeys: number, arg1: T, arg2: T, arg3: T, cb: Callback): void; (script: string, numKeys: number, arg1: T, arg2: T, cb: Callback): void; (script: string, numKeys: number, arg1: T | T[], cb: Callback): void; (script: string, numKeys: number, ...args: T[]): Promise; (script: string, numKeys: number, arg1: T[]): Promise; // This overload exists specifically to retain compatibility to `redlock` // All arguments are by default flattened, declaring all possible permuatations // would be unreasonable (and probably impossible) (args: ValueType[], callback?: Callback): any; } interface OverloadedScanCommand { (key: string, cursor: number, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, arg6: T, cb: Callback): void; (key: string, cursor: number, arg1: T, arg2: T, arg3: T, arg4: T, arg5: T, cb: Callback): void; (key: string, cursor: number, arg1: T, arg2: T, arg3: T, arg4: T, cb: Callback): void; (key: string, cursor: number, arg1: T, arg2: T, arg3: T, cb: Callback): void; (key: string, cursor: number, arg1: T, arg2: T, cb: Callback): void; (key: string, cursor: number, arg1: T | T[], cb: Callback): void; (key: string, cursor: number, cb: Callback): void; (key: string, cursor: number, ...args: T[]): Promise; (key: string, cursor: number, arg1: T[]): Promise; } type Command = _Command; interface Commands { bitcount(key: KeyType, callback: Callback): void; bitcount(key: KeyType, start: number, end: number, callback: (err: Error, res: number) => void): void; bitcount(key: KeyType): Promise; bitcount(key: KeyType, start: number, end: number): Promise; bitfield(key: KeyType, args: ValueType, callback: Callback): void; bitfield(key: KeyType, args: ValueType): Promise; get(key: KeyType, callback: Callback): void; get(key: KeyType): Promise; getdel(key: KeyType, callback: Callback): void; getdel(key: KeyType): Promise; getBuffer(key: KeyType, callback: Callback): void; getBuffer(key: KeyType): Promise; getex(key: KeyType, expiryMode?: string, time?: number | string): Promise; getex(key: KeyType, callback: Callback): void; getex(key: KeyType, expiryMode: string, time: number | string, callback: Callback): void; set( key: KeyType, value: ValueType, expiryMode?: string | any[], time?: number | string, setMode?: number | string, ): Promise; set(key: KeyType, value: ValueType, callback: Callback): void; set(key: KeyType, value: ValueType, setMode: string | any[], callback: Callback): void; set(key: KeyType, value: ValueType, expiryMode: string, time: number | string, callback: Callback): void; set( key: KeyType, value: ValueType, expiryMode: string, time: number | string, setMode: number | string, callback: Callback, ): void; setBuffer( key: KeyType, value: ValueType, expiryMode?: string | any[], time?: number | string, setMode?: number | string, ): Promise; setBuffer(key: KeyType, value: ValueType, callback: Callback): void; setBuffer(key: KeyType, value: ValueType, setMode: string, callback: Callback): void; setBuffer(key: KeyType, value: ValueType, expiryMode: string, time: number, callback: Callback): void; setBuffer( key: KeyType, value: ValueType, expiryMode: string, time: number | string, setMode: number | string, callback: Callback, ): void; setnx(key: KeyType, value: ValueType, callback: Callback): void; setnx(key: KeyType, value: ValueType): Promise; setex(key: KeyType, seconds: number, value: ValueType, callback: Callback): void; setex(key: KeyType, seconds: number, value: ValueType): Promise; psetex(key: KeyType, milliseconds: number, value: ValueType, callback: Callback): void; psetex(key: KeyType, milliseconds: number, value: ValueType): Promise; append(key: KeyType, value: ValueType, callback: Callback): void; append(key: KeyType, value: ValueType): Promise; strlen(key: KeyType, callback: Callback): void; strlen(key: KeyType): Promise; del: OverloadedListCommand; unlink: OverloadedListCommand; exists(...keys: KeyType[]): Promise; exists(key: KeyType, callback: Callback): void; setbit(key: KeyType, offset: number, value: ValueType, callback: Callback): void; setbit(key: KeyType, offset: number, value: ValueType): Promise; getbit(key: KeyType, offset: number, callback: Callback): void; getbit(key: KeyType, offset: number): Promise; setrange(key: KeyType, offset: number, value: ValueType, callback: Callback): void; setrange(key: KeyType, offset: number, value: ValueType): Promise; getrange(key: KeyType, start: number, end: number, callback: Callback): void; getrange(key: KeyType, start: number, end: number): Promise; getrangeBuffer(key: KeyType, start: number, end: number, callback: Callback): void; getrangeBuffer(key: KeyType, start: number, end: number): Promise; substr(key: KeyType, start: number, end: number, callback: Callback): void; substr(key: KeyType, start: number, end: number): Promise; incr(key: KeyType, callback: Callback): void; incr(key: KeyType): Promise; decr(key: KeyType, callback: Callback): void; decr(key: KeyType): Promise; mget: OverloadedListCommand>; mgetBuffer: OverloadedListCommand>; rpush: OverloadedKeyCommand; rpushBuffer: OverloadedKeyCommand; lpush: OverloadedKeyCommand; lpushBuffer: OverloadedKeyCommand; rpushx: OverloadedKeyCommand; lpushx: OverloadedKeyCommand; linsert( key: KeyType, direction: 'BEFORE' | 'AFTER', pivot: string, value: ValueType, callback: Callback, ): void; linsert(key: KeyType, direction: 'BEFORE' | 'AFTER', pivot: string, value: ValueType): Promise; rpop(key: KeyType, callback: Callback): void; rpop(key: KeyType): Promise; rpop(key: KeyType, count: number, callback: Callback): void; rpop(key: KeyType, count: number): Promise; lpop(key: KeyType, callback: Callback): void; lpop(key: KeyType): Promise; lpop(key: KeyType, count: number, callback: Callback): void; lpop(key: KeyType, count: number): Promise; lpos(key: KeyType, value: ValueType, rank?: number, count?: number, maxlen?: number): Promise; lpopBuffer(key: KeyType, callback: Callback): void; lpopBuffer(key: KeyType): Promise; brpop: OverloadedBlockingListCommand; blpop: OverloadedBlockingListCommand; brpoplpush(source: string, destination: string, timeout: number, callback: Callback): void; brpoplpush(source: string, destination: string, timeout: number): Promise; blmove(source: KeyType, destination: KeyType, whereFrom: 'LEFT' | 'RIGHT', whereTo: 'LEFT' | 'RIGHT', timeout: number, callback: Callback): void; blmove(source: KeyType, destination: KeyType, whereFrom: 'LEFT' | 'RIGHT', whereTo: 'LEFT' | 'RIGHT', timeout: number): Promise; lmove(source: KeyType, destination: KeyType, whereFrom: 'LEFT' | 'RIGHT', whereTo: 'LEFT' | 'RIGHT', callback: Callback): void; lmove(source: KeyType, destination: KeyType, whereFrom: 'LEFT' | 'RIGHT', whereTo: 'LEFT' | 'RIGHT'): Promise; llen(key: KeyType, callback: Callback): void; llen(key: KeyType): Promise; lindex(key: KeyType, index: number, callback: Callback): void; lindex(key: KeyType, index: number): Promise; lindexBuffer(key: KeyType, index: number, callback: Callback): void; lindexBuffer(key: KeyType, index: number): Promise; lset(key: KeyType, index: number, value: ValueType, callback: Callback): void; lset(key: KeyType, index: number, value: ValueType): Promise; lrange(key: KeyType, start: number, stop: number, callback: Callback): void; lrange(key: KeyType, start: number, stop: number): Promise; lrangeBuffer(key: KeyType, start: number, stop: number, callback: Callback): void; lrangeBuffer(key: KeyType, start: number, stop: number): Promise; ltrim(key: KeyType, start: number, stop: number, callback: Callback): void; ltrim(key: KeyType, start: number, stop: number): Promise; lrem(key: KeyType, count: number, value: ValueType, callback: Callback): void; lrem(key: KeyType, count: number, value: ValueType): Promise; rpoplpush(source: string, destination: string, callback: Callback): void; rpoplpush(source: string, destination: string): Promise; rpoplpushBuffer(source: string, destination: string, callback: Callback): void; rpoplpushBuffer(source: string, destination: string): Promise; sadd: OverloadedKeyCommand; srem: OverloadedKeyCommand; smove(source: string, destination: string, member: string, callback: Callback): void; smove(source: string, destination: string, member: string): Promise; sismember(key: KeyType, member: string, callback: Callback): void; sismember(key: KeyType, member: string): Promise; smismember(key: KeyType, ...members: string[]): Promise; scard(key: KeyType, callback: Callback): void; scard(key: KeyType): Promise; spop(key: KeyType, callback: Callback): void; spop(key: KeyType): Promise; spop(key: KeyType, count: number, callback: Callback): void; spop(key: KeyType, count: number): Promise; srandmember(key: KeyType, callback: Callback): void; srandmember(key: KeyType): Promise; srandmember(key: KeyType, count: number, callback: Callback): void; srandmember(key: KeyType, count: number): Promise; sinter: OverloadedListCommand; sinterstore: OverloadedKeyCommand; sunion: OverloadedListCommand; sunionstore: OverloadedKeyCommand; sdiff: OverloadedListCommand; sdiffstore: OverloadedKeyCommand; smembers(key: KeyType, callback: Callback): void; smembers(key: KeyType): Promise; zadd: OverloadedKeyCommand; zaddBuffer(key: KeyType, score1: number, member1: Buffer, callback: Callback): void; zaddBuffer(key: KeyType, score1: number, member1: Buffer): Promise; zincrby(key: KeyType, increment: number, member: string, callback: Callback): void; zincrby(key: KeyType, increment: number, member: string): Promise; zpopmin(key: KeyType, callback: Callback): void; zpopmin(key: KeyType, count: number, callback: Callback): void; zpopmin(key: KeyType, count?: number): Promise; zpopmax(key: KeyType, callback: Callback): void; zpopmax(key: KeyType, count: number, callback: Callback): void; zpopmax(key: KeyType, count?: number): Promise; bzpopmin: OverloadedBlockingListCommand; bzpopmax: OverloadedBlockingListCommand; zrem: OverloadedKeyCommand; zremrangebyscore(key: KeyType, min: number | string, max: number | string, callback: Callback): void; zremrangebyscore(key: KeyType, min: number | string, max: number | string): Promise; zremrangebyrank(key: KeyType, start: number, stop: number, callback: Callback): void; zremrangebyrank(key: KeyType, start: number, stop: number): Promise; zremrangebylex(key: KeyType, min: string, max: string): Promise; zremrangebylex(key: KeyType, min: string, max: string, callback: Callback): void; zunionstore: OverloadedKeyCommand; zinterstore: OverloadedKeyCommand; zrange(key: KeyType, start: number, stop: number, callback: Callback): void; zrange(key: KeyType, start: number, stop: number, withScores: 'WITHSCORES', callback: Callback): void; zrange(key: KeyType, start: number, stop: number, withScores?: 'WITHSCORES'): Promise; zrangeBuffer(key: KeyType, start: number, stop: number, callback: Callback): void; zrangeBuffer( key: KeyType, start: number, stop: number, withScores: 'WITHSCORES', callback: Callback, ): void; zrangeBuffer(key: KeyType, start: number, stop: number, withScores?: 'WITHSCORES'): Promise; zrevrange(key: KeyType, start: number, stop: number, callback: Callback): void; zrevrange( key: KeyType, start: number, stop: number, withScores: 'WITHSCORES', callback: Callback, ): void; zrevrange(key: KeyType, start: number, stop: number, withScores?: 'WITHSCORES'): Promise; zrevrangeBuffer(key: KeyType, start: number, stop: number, callback: Callback): void; zrevrangeBuffer( key: KeyType, start: number, stop: number, withScores: 'WITHSCORES', callback: Callback, ): void; zrevrangeBuffer(key: KeyType, start: number, stop: number, withScores?: 'WITHSCORES'): Promise; zrangebyscore( key: KeyType, min: number | string, max: number | string, withScores?: 'WITHSCORES', ): Promise; zrangebyscore( key: KeyType, min: number | string, max: number | string, withScores: 'WITHSCORES', limit: 'LIMIT', offset: number, count: number, ): Promise; zrangebyscore( key: KeyType, min: number | string, max: number | string, limit: 'LIMIT', offset: number, count: number, ): Promise; zrangebyscore(key: KeyType, min: number | string, max: number | string, callback: Callback): void; zrangebyscore( key: KeyType, min: number | string, max: number | string, withScores: 'WITHSCORES', callback: Callback, ): void; zrangebyscore( key: KeyType, min: number | string, max: number | string, withScores: 'WITHSCORES', limit: 'LIMIT', offset: number, count: number, callback: Callback, ): void; zrangebyscore( key: KeyType, min: number | string, max: number | string, limit: 'LIMIT', offset: number, count: number, callback: Callback, ): void; zrangebyscoreBuffer( key: KeyType, min: number | string, max: number | string, withScores?: 'WITHSCORES', ): Promise; zrangebyscoreBuffer( key: KeyType, min: number | string, max: number | string, withScores: 'WITHSCORES', limit: 'LIMIT', offset: number, count: number, ): Promise; zrangebyscoreBuffer( key: KeyType, min: number | string, max: number | string, limit: 'LIMIT', offset: number, count: number, ): Promise; zrangebyscoreBuffer( key: KeyType, min: number | string, max: number | string, callback: Callback, ): void; zrangebyscoreBuffer( key: KeyType, min: number | string, max: number | string, withScores: 'WITHSCORES', callback: Callback, ): void; zrangebyscoreBuffer( key: KeyType, min: number | string, max: number | string, withScores: 'WITHSCORES', limit: 'LIMIT', offset: number, count: number, callback: Callback, ): void; zrangebyscoreBuffer( key: KeyType, min: number | string, max: number | string, limit: 'LIMIT', offset: number, count: number, callback: Callback, ): void; zrevrangebyscore( key: KeyType, max: number | string, min: number | string, withScores?: 'WITHSCORES', ): Promise; zrevrangebyscore( key: KeyType, max: number | string, min: number | string, withScores: 'WITHSCORES', limit: 'LIMIT', offset: number, count: number, ): Promise; zrevrangebyscore( key: KeyType, max: number | string, min: number | string, limit: 'LIMIT', offset: number, count: number, ): Promise; zrevrangebyscore(key: KeyType, max: number | string, min: number | string, callback: Callback): void; zrevrangebyscore( key: KeyType, max: number | string, min: number | string, withScores: 'WITHSCORES', callback: Callback, ): void; zrevrangebyscore( key: KeyType, max: number | string, min: number | string, withScores: 'WITHSCORES', limit: 'LIMIT', offset: number, count: number, callback: Callback, ): void; zrevrangebyscore( key: KeyType, max: number | string, min: number | string, limit: 'LIMIT', offset: number, count: number, callback: Callback, ): void; zrevrangebyscoreBuffer( key: KeyType, max: number | string, min: number | string, withScores?: 'WITHSCORES', ): Promise; zrevrangebyscoreBuffer( key: KeyType, max: number | string, min: number | string, withScores: 'WITHSCORES', limit: 'LIMIT', offset: number, count: number, ): Promise; zrevrangebyscoreBuffer( key: KeyType, max: number | string, min: number | string, limit: 'LIMIT', offset: number, count: number, ): Promise; zrevrangebyscoreBuffer( key: KeyType, max: number | string, min: number | string, callback: Callback, ): void; zrevrangebyscoreBuffer( key: KeyType, max: number | string, min: number | string, withScores: 'WITHSCORES', callback: Callback, ): void; zrevrangebyscoreBuffer( key: KeyType, max: number | string, min: number | string, withScores: 'WITHSCORES', limit: 'LIMIT', offset: number, count: number, callback: Callback, ): void; zrevrangebyscoreBuffer( key: KeyType, max: number | string, min: number | string, limit: 'LIMIT', offset: number, count: number, callback: Callback, ): void; zrangebylex(key: KeyType, min: string, max: string): Promise; zrangebylex( key: KeyType, min: string, max: string, limit: 'LIMIT', offset: number, count: number, ): Promise; zrangebylex(key: KeyType, min: string, max: string, callback: Callback): void; zrangebylex( key: KeyType, min: string, max: string, limit: 'LIMIT', offset: number, count: number, callback: Callback, ): void; zrangebylexBuffer(key: KeyType, min: string, max: string): Promise; zrangebylexBuffer( key: KeyType, min: string, max: string, limit: 'LIMIT', offset: number, count: number, ): Promise; zrangebylexBuffer(key: KeyType, min: string, max: string, callback: Callback): void; zrangebylexBuffer( key: KeyType, min: string, max: string, limit: 'LIMIT', offset: number, count: number, callback: Callback, ): void; zrevrangebylex(key: KeyType, max: string, min: string): Promise; zrevrangebylex( key: KeyType, max: string, min: string, limit: 'LIMIT', offset: number, count: number, ): Promise; zrevrangebylex(key: KeyType, max: string, min: string, callback: Callback): void; zrevrangebylex( key: KeyType, max: string, min: string, limit: 'LIMIT', offset: number, count: number, callback: Callback, ): void; zrevrangebylexBuffer(key: KeyType, min: string, max: string): Promise; zrevrangebylexBuffer( key: KeyType, min: string, max: string, limit: 'LIMIT', offset: number, count: number, ): Promise; zrevrangebylexBuffer(key: KeyType, min: string, max: string, callback: Callback): void; zrevrangebylexBuffer( key: KeyType, min: string, max: string, limit: 'LIMIT', offset: number, count: number, callback: Callback, ): void; zcount(key: KeyType, min: number | string, max: number | string, callback: Callback): void; zcount(key: KeyType, min: number | string, max: number | string): Promise; zcard(key: KeyType, callback: Callback): void; zcard(key: KeyType): Promise; zscore(key: KeyType, member: string, callback: Callback): void; zscore(key: KeyType, member: string): Promise; zmscore: OverloadedKeyCommand>; zrank(key: KeyType, member: string, callback: Callback): void; zrank(key: KeyType, member: string): Promise; zrevrank(key: KeyType, member: string, callback: Callback): void; zrevrank(key: KeyType, member: string): Promise; hset: OverloadedKeyedHashCommand; hsetBuffer(key: KeyType, field: string, value: ValueType, callback: Callback): void; hsetBuffer(key: KeyType, field: string, value: ValueType): Promise; hsetnx(key: KeyType, field: string, value: ValueType, callback: Callback): void; hsetnx(key: KeyType, field: string, value: ValueType): Promise; hget(key: KeyType, field: string, callback: Callback): void; hget(key: KeyType, field: string): Promise; hgetBuffer(key: KeyType, field: string, callback: Callback): void; hgetBuffer(key: KeyType, field: string): Promise; hmset: OverloadedKeyedHashCommand; hmget: OverloadedKeyCommand>; hmgetBuffer: OverloadedKeyCommand>; hstrlen(key: KeyType, field: string, callback: Callback): void; hstrlen(key: KeyType, field: string): Promise; hincrby(key: KeyType, field: string, increment: number, callback: Callback): void; hincrby(key: KeyType, field: string, increment: number): Promise; hincrbyfloat(key: KeyType, field: string, increment: number, callback: Callback): void; hincrbyfloat(key: KeyType, field: string, increment: number): Promise; hdel: OverloadedKeyCommand; hlen(key: KeyType, callback: Callback): void; hlen(key: KeyType): Promise; hkeys(key: KeyType, callback: Callback): void; hkeys(key: KeyType): Promise; hvals(key: KeyType, callback: Callback): void; hvals(key: KeyType): Promise; hgetall(key: KeyType, callback: Callback>): void; hgetall(key: KeyType): Promise>; hexists(key: KeyType, field: string, callback: Callback): void; hexists(key: KeyType, field: string): Promise; geoadd(key: KeyType, longitude: number, latitude: number, member: string, callback: Callback): void; geoadd(key: KeyType, longitude: number, latitude: number, member: string): Promise; geodist( key: KeyType, member1: string, member2: string, unit: 'm' | 'km' | 'ft' | 'mi', callback: Callback, ): void; geodist(key: KeyType, member1: string, member2: string, unit: 'm' | 'km' | 'ft' | 'mi'): Promise; geohash: OverloadedKeyCommand; geopos: OverloadedKeyCommand; georadius( key: KeyType, longitude: number, latitude: number, radius: number, unit: 'm' | 'km' | 'ft' | 'mi', callback: Callback, ): void; georadius( key: KeyType, longitude: number, latitude: number, radius: number, unit: 'm' | 'km' | 'ft' | 'mi', sort?: 'ASC' | 'DESC', ): Promise; georadius( key: KeyType, longitude: number, latitude: number, radius: number, unit: 'm' | 'km' | 'ft' | 'mi', count: 'COUNT', countValue: number, sort?: 'ASC' | 'DESC', ): Promise; georadiusbymember( key: KeyType, member: string, radius: number, unit: 'm' | 'km' | 'ft' | 'mi', callback: Callback, ): void; georadiusbymember( key: KeyType, member: string, radius: number, unit: 'm' | 'km' | 'ft' | 'mi', count: 'COUNT', countValue: number, callback: Callback, ): void; georadiusbymember( key: KeyType, member: string, radius: number, unit: 'm' | 'km' | 'ft' | 'mi', ): Promise; georadiusbymember( key: KeyType, member: string, radius: number, unit: 'm' | 'km' | 'ft' | 'mi', count: 'COUNT', countValue: number, ): Promise; /** * https://redis.io/commands/geosearch */ geosearch( key: KeyType, from: 'FROMMEMBER', member: string, by: 'BYRADIUS', radius: number, radiusUnit: 'm' | 'km' | 'ft' | 'mi', count: 'COUNT', countValue: number, sort?: 'ASC' | 'DESC', withCoord?: 'WITHCOORD', withDist?: 'WITHDIST', withHash?: 'WITHHASH', ): Promise>; geosearch( key: KeyType, from: 'FROMMEMBER', member: string, by: 'BYBOX', width: number, height: number, unit: 'm' | 'km' | 'ft' | 'mi', count: 'COUNT', countValue: number, sort?: 'ASC' | 'DESC', withCoord?: 'WITHCOORD', withDist?: 'WITHDIST', withHash?: 'WITHHASH', ): Promise>; geosearch( key: KeyType, from: 'FROMLONLAT', longitude: number, latitude: number, by: 'BYRADIUS', radius: number, radiusUnit: 'm' | 'km' | 'ft' | 'mi', count: 'COUNT', countValue: number, sort?: 'ASC' | 'DESC', withCoord?: 'WITHCOORD', withDist?: 'WITHDIST', withHash?: 'WITHHASH', ): Promise>; geosearch( key: KeyType, from: 'FROMLONLAT', longitude: number, latitude: number, by: 'BYBOX', width: number, height: number, unit: 'm' | 'km' | 'ft' | 'mi', count: 'COUNT', countValue: number, sort?: 'ASC' | 'DESC', withCoord?: 'WITHCOORD', withDist?: 'WITHDIST', withHash?: 'WITHHASH', ): Promise>; // without count geosearch( key: KeyType, from: 'FROMMEMBER', member: string, by: 'BYRADIUS', radius: number, radiusUnit: 'm' | 'km' | 'ft' | 'mi', sort?: 'ASC' | 'DESC', withCoord?: 'WITHCOORD', withDist?: 'WITHDIST', withHash?: 'WITHHASH', ): Promise>; geosearch( key: KeyType, from: 'FROMMEMBER', member: string, by: 'BYBOX', width: number, height: number, unit: 'm' | 'km' | 'ft' | 'mi', sort?: 'ASC' | 'DESC', withCoord?: 'WITHCOORD', withDist?: 'WITHDIST', withHash?: 'WITHHASH', ): Promise>; geosearch( key: KeyType, from: 'FROMLONLAT', longitude: number, latitude: number, by: 'BYRADIUS', radius: number, radiusUnit: 'm' | 'km' | 'ft' | 'mi', sort?: 'ASC' | 'DESC', withCoord?: 'WITHCOORD', withDist?: 'WITHDIST', withHash?: 'WITHHASH', ): Promise>; geosearch( key: KeyType, from: 'FROMLONLAT', longitude: number, latitude: number, by: 'BYBOX', width: number, height: number, unit: 'm' | 'km' | 'ft' | 'mi', sort?: 'ASC' | 'DESC', withCoord?: 'WITHCOORD', withDist?: 'WITHDIST', withHash?: 'WITHHASH', ): Promise>; incrby(key: KeyType, increment: number, callback: Callback): void; incrby(key: KeyType, increment: number): Promise; incrbyfloat(key: KeyType, increment: number, callback: Callback): void; incrbyfloat(key: KeyType, increment: number): Promise; decrby(key: KeyType, decrement: number, callback: Callback): void; decrby(key: KeyType, decrement: number): Promise; getset(key: KeyType, value: ValueType, callback: Callback): void; getset(key: KeyType, value: ValueType): Promise; mset: OverloadedHashCommand; msetBuffer: OverloadedHashCommand; msetnx: OverloadedHashCommand; memory(argument: 'USAGE', key: KeyType, callback?: Callback): Promise; randomkey(callback: Callback): void; randomkey(): Promise; select(index: number, callback: Callback): void; select(index: number): Promise; move(key: KeyType, db: string, callback: Callback): void; move(key: KeyType, db: string): Promise; rename(key: KeyType, newkey: KeyType, callback: Callback): void; rename(key: KeyType, newkey: KeyType): Promise; renamenx(key: KeyType, newkey: KeyType, callback: Callback): void; renamenx(key: KeyType, newkey: KeyType): Promise; expire(key: KeyType, seconds: number, callback: Callback): void; expire(key: KeyType, seconds: number): Promise; pexpire(key: KeyType, milliseconds: number, callback: Callback): void; pexpire(key: KeyType, milliseconds: number): Promise; expireat(key: KeyType, timestamp: number, callback: Callback): void; expireat(key: KeyType, timestamp: number): Promise; pexpireat(key: KeyType, millisecondsTimestamp: number, callback: Callback): void; pexpireat(key: KeyType, millisecondsTimestamp: number): Promise; keys(pattern: string, callback: Callback): void; keys(pattern: string): Promise; dbsize(callback: Callback): void; dbsize(): Promise; auth(username: string, password: string, callback: Callback): void; auth(password: string, callback: Callback): void; // tslint:disable-next-line unified-signatures auth(username: string, password: string): Promise; auth(password: string): Promise; ping(callback: Callback): void; ping(message: string, callback: Callback): void; ping(message?: string): Promise; echo(message: string, callback: Callback): void; echo(message: string): Promise; save(callback: Callback): void; save(): Promise; bgsave(callback: Callback): void; bgsave(): Promise; bgrewriteaof(callback: Callback): void; bgrewriteaof(): Promise; shutdown(save: 'SAVE' | 'NOSAVE', callback: Callback): void; shutdown(save: 'SAVE' | 'NOSAVE'): Promise; lastsave(callback: Callback): void; lastsave(): Promise; type(key: KeyType, callback: Callback): void; type(key: KeyType): Promise; multi(commands?: string[][], options?: MultiOptions): Pipeline; multi(options: { pipeline: false }): Promise; exec(callback: Callback>): void; exec(): Promise>; discard(callback: Callback): void; discard(): Promise; sync(callback: Callback): void; sync(): Promise; flushdb(callback: Callback): void; flushdb(option?: 'async' | 'sync'): Promise; flushall(callback: Callback): void; flushall(): Promise; sort: OverloadedListCommand; info(callback: Callback): void; info(section: string, callback: Callback): void; info(section?: string): Promise; time(callback: Callback<[string, string]>): void; time(): Promise<[string, string]>; monitor(callback: Callback): void; monitor(): Promise; ttl(key: KeyType, callback: Callback): void; ttl(key: KeyType): Promise; pttl(key: KeyType, callback: Callback): void; pttl(key: KeyType): Promise; persist(key: KeyType, callback: Callback): void; persist(key: KeyType): Promise; slaveof(host: string, port: number, callback: Callback): void; slaveof(host: string, port: number): Promise; debug: OverloadedSubCommand; config(op: 'GET', cfg: string): Promise; config(op: 'GET', cfg: string, callback: Callback): void; config(op: 'REWRITE' | 'RESETSTAT'): Promise; config(op: 'REWRITE' | 'RESETSTAT', callback: Callback): void; config(op: 'SET', key: string, value: ValueType): Promise; config(op: 'SET', key: string, value: ValueType, callback: Callback): void; subscribe: OverloadedListCommand; unsubscribe: OverloadedCommand; psubscribe: OverloadedListCommand; punsubscribe: OverloadedCommand; publish(channel: string, message: string, callback: Callback): void; publish(channel: string, message: string): Promise; publishBuffer(channel: string, message: Buffer): Promise; watch: OverloadedListCommand; unwatch(callback: Callback): void; unwatch(): Promise; cluster: OverloadedSubCommand; restore: OverloadedListCommand; migrate: OverloadedListCommand; dump(key: KeyType, callback: Callback): void; dump(key: KeyType): Promise; object: OverloadedListCommand; client: OverloadedSubCommand; eval: OverloadedEvalCommand; evalsha: OverloadedEvalCommand; script: OverloadedSubCommand; quit(callback: Callback): void; quit(): Promise; scan(cursor: number | string): Promise<[string, string[]]>; scan(cursor: number | string, matchOption: 'match' | 'MATCH', pattern: string): Promise<[string, string[]]>; scan( cursor: number | string, matchOption: 'match' | 'MATCH', pattern: string, callback: Callback<[string, string[]]>, ): void; scan(cursor: number | string, countOption: 'count' | 'COUNT', count: number): Promise<[string, string[]]>; scan( cursor: number | string, countOption: 'count' | 'COUNT', count: number, callback: Callback<[string, string[]]>, ): void; scan( cursor: number | string, matchOption: 'match' | 'MATCH', pattern: string, countOption: 'count' | 'COUNT', count: number, ): Promise<[string, string[]]>; scan( cursor: number | string, matchOption: 'match' | 'MATCH', pattern: string, countOption: 'count' | 'COUNT', count: number, callback: Callback<[string, string[]]>, ): void; scan( cursor: number | string, countOption: 'count' | 'COUNT', count: number, matchOption: 'match' | 'MATCH', pattern: string, ): Promise<[string, string[]]>; scan( cursor: number | string, countOption: 'count' | 'COUNT', count: number, matchOption: 'match' | 'MATCH', pattern: string, callback: Callback<[string, string[]]>, ): void; sscan: OverloadedKeyCommand; hscan: OverloadedKeyCommand; zscan: OverloadedKeyCommand; pfmerge: OverloadedKeyCommand; pfadd: OverloadedKeyCommand; pfcount: OverloadedListCommand; pipeline(commands?: string[][]): Pipeline; scanStream(options?: ScanStreamOption): Readable; sscanStream(key: KeyType, options?: ScanStreamOption): Readable; hscanStream(key: KeyType, options?: ScanStreamOption): Readable; zscanStream(key: KeyType, options?: ScanStreamOption): Readable; xack: OverloadedKeyCommand; xadd: OverloadedKeyCommand; xclaim: OverloadedKeyCommand>; xautoclaim: OverloadedSubCommand]>; xdel: OverloadedKeyCommand; xgroup: OverloadedSubCommand; xinfo: OverloadedSubCommand; xlen(key: KeyType): Promise; xlen(key: KeyType, callback: Callback): void; xpending: OverloadedKeyCommand; xrange: OverloadedKeyCommand>; xread: OverloadedListCommand]>>; xreadgroup: OverloadedKeyCommand]>>; xrevrange: OverloadedKeyCommand>; xtrim: OverloadedKeyCommand; } interface Redis extends EventEmitter, Commander, Commands { Promise: typeof Promise; readonly options: RedisOptions; readonly status: string; connect(callback?: () => void): Promise; disconnect(reconnect?: boolean): void; duplicate(): Redis; send_command(command: string, ...args: ValueType[]): Promise; } interface Pipeline { readonly redis: Redis | Cluster; readonly isCluster: boolean; readonly options: RedisOptions | ClusterOptions; readonly length: number; bitcount(key: KeyType, callback?: Callback): Pipeline; bitcount(key: KeyType, start: number, end: number, callback?: Callback): Pipeline; bitfield(key: KeyType, args: ValueType, callback?: Callback): Pipeline; get(key: KeyType, callback?: Callback): Pipeline; getBuffer(key: KeyType, callback?: Callback): Pipeline; getex(key: KeyType, expiryMode: string, time: number, callback?: Callback): Pipeline; set(key: KeyType, value: ValueType, callback?: Callback): Pipeline; set(key: KeyType, value: ValueType, setMode: string, callback?: Callback): Pipeline; set(key: KeyType, value: ValueType, expiryMode: string, time: number, callback?: Callback): Pipeline; set( key: KeyType, value: ValueType, expiryMode: string, time: number, setMode: string, callback?: Callback, ): Pipeline; setBuffer(key: KeyType, value: ValueType, callback?: Callback): Pipeline; setBuffer(key: KeyType, value: ValueType, setMode: string, callback?: Callback): Pipeline; setBuffer( key: KeyType, value: ValueType, expiryMode: string, time: number, callback?: Callback, ): Pipeline; setBuffer( key: KeyType, value: ValueType, expiryMode: string, time: number, setMode: string, callback?: Callback, ): Pipeline; setnx(key: KeyType, value: ValueType, callback?: Callback): Pipeline; setex(key: KeyType, seconds: number, value: ValueType, callback?: Callback): Pipeline; psetex(key: KeyType, milliseconds: number, value: ValueType, callback?: Callback): Pipeline; append(key: KeyType, value: ValueType, callback?: Callback): Pipeline; strlen(key: KeyType, callback?: Callback): Pipeline; del(...keys: KeyType[]): Pipeline; unlink(...keys: KeyType[]): Pipeline; exists(...keys: KeyType[]): Pipeline; setbit(key: KeyType, offset: number, value: ValueType, callback?: Callback): Pipeline; getbit(key: KeyType, offset: number, callback?: Callback): Pipeline; setrange(key: KeyType, offset: number, value: ValueType, callback?: Callback): Pipeline; getrange(key: KeyType, start: number, end: number, callback?: Callback): Pipeline; getrangeBuffer(key: KeyType, start: number, end: number, callback?: Callback): Pipeline; substr(key: KeyType, start: number, end: number, callback?: Callback): Pipeline; incr(key: KeyType, callback?: Callback): Pipeline; decr(key: KeyType, callback?: Callback): Pipeline; mget(...keys: KeyType[]): Pipeline; mgetBuffer(...keys: KeyType[]): Pipeline; rpush(key: KeyType, ...values: ValueType[]): Pipeline; rpushBuffer(key: string, ...values: Buffer[]): Pipeline; lpush(key: KeyType, ...values: ValueType[]): Pipeline; rpushx(key: KeyType, value: ValueType, callback?: Callback): Pipeline; rpushx(key: KeyType, ...values: ValueType[]): Pipeline; lpushx(key: KeyType, value: ValueType, callback?: Callback): Pipeline; lpushx(key: KeyType, ...values: ValueType[]): Pipeline; linsert( key: KeyType, direction: 'BEFORE' | 'AFTER', pivot: string, value: ValueType, callback?: Callback, ): Pipeline; rpop(key: KeyType, callback?: Callback): Pipeline; lpop(key: KeyType, callback?: Callback): Pipeline; lpopBuffer(key: KeyType, callback?: Callback): Pipeline; brpop(...keys: KeyType[]): Pipeline; blpop(...keys: KeyType[]): Pipeline; brpoplpush(source: string, destination: string, timeout: number, callback?: Callback): Pipeline; llen(key: KeyType, callback?: Callback): Pipeline; lindex(key: KeyType, index: number, callback?: Callback): Pipeline; lset(key: KeyType, index: number, value: ValueType, callback?: Callback): Pipeline; lrange(key: KeyType, start: number, stop: number, callback?: Callback): Pipeline; lrangeBuffer(key: KeyType, start: number, stop: number, callback?: Callback): Pipeline; ltrim(key: KeyType, start: number, stop: number, callback?: Callback): Pipeline; lrem(key: KeyType, count: number, value: ValueType, callback?: Callback): Pipeline; rpoplpush(source: string, destination: string, callback?: Callback): Pipeline; sadd(key: KeyType, ...members: ValueType[]): Pipeline; srem(key: KeyType, ...members: ValueType[]): Pipeline; smove(source: string, destination: string, member: string, callback?: Callback): Pipeline; sismember(key: KeyType, member: string, callback?: Callback): Pipeline; scard(key: KeyType, callback?: Callback): Pipeline; spop(key: KeyType, callback?: Callback): Pipeline; spop(key: KeyType, count: number, callback?: Callback): Pipeline; srandmember(key: KeyType, callback?: Callback): Pipeline; srandmember(key: KeyType, count: number, callback?: Callback): Pipeline; sinter(...keys: KeyType[]): Pipeline; sinterstore(destination: string, ...keys: KeyType[]): Pipeline; sunion(...keys: KeyType[]): Pipeline; sunionstore(destination: string, ...keys: KeyType[]): Pipeline; sdiff(...keys: KeyType[]): Pipeline; sdiffstore(destination: string, ...keys: KeyType[]): Pipeline; smembers(key: KeyType, callback?: Callback): Pipeline; zadd(key: KeyType, ...scoresAndMembers: Array): Pipeline; zincrby(key: KeyType, increment: number, member: string, callback?: Callback): Pipeline; zpopmin(key: KeyType, count: number, callback?: Callback): Pipeline; zpopmax(key: KeyType, count: number, callback?: Callback): Pipeline; bzpopmin(...args: Array>): Pipeline; bzpopmax(...args: Array>): Pipeline; zrem(key: KeyType, ...members: ValueType[]): Pipeline; zremrangebyscore( key: KeyType, min: number | string, max: number | string, callback?: Callback, ): Pipeline; zremrangebyrank(key: KeyType, start: number, stop: number, callback?: Callback): Pipeline; zremrangebylex(key: KeyType, min: string, max: string, callback?: Callback): Pipeline; zunionstore(destination: string, numkeys: number, key: KeyType, ...args: string[]): Pipeline; zinterstore(destination: string, numkeys: number, key: KeyType, ...args: string[]): Pipeline; zrange(key: KeyType, start: number, stop: number, callback?: Callback): Pipeline; zrange( key: KeyType, start: number, stop: number, withScores: 'WITHSCORES', callback?: Callback, ): Pipeline; zrevrange(key: KeyType, start: number, stop: number, callback?: Callback): Pipeline; zrevrange( key: KeyType, start: number, stop: number, withScores: 'WITHSCORES', callback?: Callback, ): Pipeline; zrangebyscore(key: KeyType, min: number | string, max: number | string, ...args: string[]): Pipeline; zrevrangebyscore(key: KeyType, max: number | string, min: number | string, ...args: string[]): Pipeline; zrangebylex(key: KeyType, min: string, max: string, callback?: Callback): Pipeline; zrangebylex( key: KeyType, min: string, max: string, limit: 'LIMIT', offset: number, count: number, callback?: Callback, ): Pipeline; zrevrangebylex(key: KeyType, min: string, max: string, callback?: Callback): Pipeline; zrevrangebylex( key: KeyType, min: string, max: string, limit: 'LIMIT', offset: number, count: number, callback?: Callback, ): Pipeline; zcount(key: KeyType, min: number | string, max: number | string, callback?: Callback): Pipeline; zcard(key: KeyType, callback?: Callback): Pipeline; zscore(key: KeyType, member: string, callback?: Callback): Pipeline; zmscore(key: KeyType, ...members: string[]): Pipeline; zrank(key: KeyType, member: string, callback?: Callback): Pipeline; zrevrank(key: KeyType, member: string, callback?: Callback): Pipeline; hset(key: KeyType, ...args: ValueType[]): Pipeline; hset(key: KeyType, data: object | Map, callback?: Callback): Pipeline; hset(key: KeyType, field: string, value: ValueType, callback?: Callback): Pipeline; hsetBuffer(key: KeyType, field: string, value: ValueType, callback?: Callback): Pipeline; hsetnx(key: KeyType, field: string, value: ValueType, callback?: Callback): Pipeline; hget(key: KeyType, field: string, callback?: Callback): Pipeline; hgetBuffer(key: KeyType, field: string, callback?: Callback): Pipeline; hmset(key: KeyType, ...args: ValueType[]): Pipeline; hmset(key: KeyType, data: object | Map, callback?: Callback): Pipeline; hmget(key: KeyType, ...fields: string[]): Pipeline; hstrlen(key: KeyType, field: string, callback?: Callback): Pipeline; hincrby(key: KeyType, field: string, increment: number, callback?: Callback): Pipeline; hincrbyfloat(key: KeyType, field: string, increment: number, callback?: Callback): Pipeline; hdel(key: KeyType, ...fields: string[]): Pipeline; hlen(key: KeyType, callback?: Callback): Pipeline; hkeys(key: KeyType, callback?: Callback): Pipeline; hvals(key: KeyType, callback?: Callback): Pipeline; hgetall(key: KeyType, callback?: Callback>): Pipeline; hexists(key: KeyType, field: string, callback?: Callback): Pipeline; geoadd( key: KeyType, longitude: number, latitude: number, member: string, callback?: Callback, ): Pipeline; geodist( key: KeyType, member1: string, member2: string, unit: 'm' | 'km' | 'ft' | 'mi', callback?: Callback, ): Pipeline; geohash(key: KeyType, ...fields: string[]): Pipeline; geopos(key: KeyType, ...fields: string[]): Pipeline; georadius( key: KeyType, longitude: number, latitude: number, radius: number, unit: 'm' | 'km' | 'ft' | 'mi', callback?: Callback, ): Pipeline; georadius( key: KeyType, longitude: number, latitude: number, radius: number, unit: 'm' | 'km' | 'ft' | 'mi', count: 'COUNT', countValue: number, callback?: Callback, ): Pipeline; georadiusbymember( key: KeyType, member: string, radius: number, unit: 'm' | 'km' | 'ft' | 'mi', callback?: Callback, ): Pipeline; georadiusbymember( key: KeyType, member: string, radius: number, unit: 'm' | 'km' | 'ft' | 'mi', count: 'COUNT', countValue: number, callback?: Callback, ): Pipeline; /** * https://redis.io/commands/geosearch */ geosearch( key: KeyType, from: 'FROMMEMBER', member: string, by: 'BYRADIUS', radius: number, radiusUnit: 'm' | 'km' | 'ft' | 'mi', count: 'COUNT', countValue: number, sort?: 'ASC' | 'DESC', withCoord?: 'WITHCOORD', withDist?: 'WITHDIST', withHash?: 'WITHHASH', ): Pipeline; geosearch( key: KeyType, from: 'FROMMEMBER', member: string, by: 'BYBOX', width: number, height: number, unit: 'm' | 'km' | 'ft' | 'mi', count: 'COUNT', countValue: number, sort?: 'ASC' | 'DESC', withCoord?: 'WITHCOORD', withDist?: 'WITHDIST', withHash?: 'WITHHASH', ): Pipeline; geosearch( key: KeyType, from: 'FROMLONLAT', longitude: number, latitude: number, by: 'BYRADIUS', radius: number, radiusUnit: 'm' | 'km' | 'ft' | 'mi', count: 'COUNT', countValue: number, sort?: 'ASC' | 'DESC', withCoord?: 'WITHCOORD', withDist?: 'WITHDIST', withHash?: 'WITHHASH', ): Pipeline; geosearch( key: KeyType, from: 'FROMLONLAT', longitude: number, latitude: number, by: 'BYBOX', width: number, height: number, unit: 'm' | 'km' | 'ft' | 'mi', count: 'COUNT', countValue: number, sort?: 'ASC' | 'DESC', withCoord?: 'WITHCOORD', withDist?: 'WITHDIST', withHash?: 'WITHHASH', ): Pipeline; // without count geosearch( key: KeyType, from: 'FROMMEMBER', member: string, by: 'BYRADIUS', radius: number, radiusUnit: 'm' | 'km' | 'ft' | 'mi', sort?: 'ASC' | 'DESC', withCoord?: 'WITHCOORD', withDist?: 'WITHDIST', withHash?: 'WITHHASH', ): Pipeline; geosearch( key: KeyType, from: 'FROMMEMBER', member: string, by: 'BYBOX', width: number, height: number, unit: 'm' | 'km' | 'ft' | 'mi', sort?: 'ASC' | 'DESC', withCoord?: 'WITHCOORD', withDist?: 'WITHDIST', withHash?: 'WITHHASH', ): Pipeline; geosearch( key: KeyType, from: 'FROMLONLAT', longitude: number, latitude: number, by: 'BYRADIUS', radius: number, radiusUnit: 'm' | 'km' | 'ft' | 'mi', sort?: 'ASC' | 'DESC', withCoord?: 'WITHCOORD', withDist?: 'WITHDIST', withHash?: 'WITHHASH', ): Pipeline; geosearch( key: KeyType, from: 'FROMLONLAT', longitude: number, latitude: number, by: 'BYBOX', width: number, height: number, unit: 'm' | 'km' | 'ft' | 'mi', sort?: 'ASC' | 'DESC', withCoord?: 'WITHCOORD', withDist?: 'WITHDIST', withHash?: 'WITHHASH', ): Pipeline; incrby(key: KeyType, increment: number, callback?: Callback): Pipeline; incrbyfloat(key: KeyType, increment: number, callback?: Callback): Pipeline; decrby(key: KeyType, decrement: number, callback?: Callback): Pipeline; getset(key: KeyType, value: ValueType, callback?: Callback): Pipeline; mset(...args: ValueType[]): Pipeline; mset(data: object | Map, callback?: Callback): Pipeline; msetBuffer(...args: ValueType[]): Pipeline; msetnx(...args: ValueType[]): Pipeline; msetnx(data: object | Map, callback?: Callback): Pipeline; memory(argument: 'USAGE', key: KeyType, callback?: Callback): Pipeline; randomkey(callback?: Callback): Pipeline; select(index: number, callback?: Callback): Pipeline; move(key: KeyType, db: string, callback?: Callback): Pipeline; rename(key: KeyType, newkey: KeyType, callback?: Callback): Pipeline; renamenx(key: KeyType, newkey: KeyType, callback?: Callback): Pipeline; expire(key: KeyType, seconds: number, callback?: Callback): Pipeline; pexpire(key: KeyType, milliseconds: number, callback?: Callback): Pipeline; expireat(key: KeyType, timestamp: number, callback?: Callback): Pipeline; pexpireat(key: KeyType, millisecondsTimestamp: number, callback?: Callback): Pipeline; keys(pattern: string, callback?: Callback): Pipeline; dbsize(callback?: Callback): Pipeline; auth(password: string, callback?: Callback): Pipeline; auth(username: string, password: string, callback?: Callback): Pipeline; ping(callback?: Callback): Pipeline; ping(message: string, callback?: Callback): Pipeline; echo(message: string, callback?: Callback): Pipeline; save(callback?: Callback): Pipeline; bgsave(callback?: Callback): Pipeline; bgrewriteaof(callback?: Callback): Pipeline; shutdown(save: 'SAVE' | 'NOSAVE', callback?: Callback): Pipeline; lastsave(callback?: Callback): Pipeline; type(key: KeyType, callback?: Callback): Pipeline; multi(callback?: Callback): Pipeline; exec(callback?: Callback>): Promise>; discard(callback?: Callback): Pipeline; sync(callback?: Callback): Pipeline; flushdb(callback?: Callback): Pipeline; flushall(callback?: Callback): Pipeline; sort(key: KeyType, ...args: string[]): Pipeline; info(callback?: Callback): Pipeline; info(section: string, callback?: Callback): Pipeline; time(callback?: Callback<[string, string]>): Pipeline; monitor(callback?: Callback): Pipeline; ttl(key: KeyType, callback?: Callback): Pipeline; pttl(key: KeyType, callback?: Callback): Pipeline; persist(key: KeyType, callback?: Callback): Pipeline; slaveof(host: string, port: number, callback?: Callback): Pipeline; debug(...args: ValueType[]): Pipeline; config(...args: ValueType[]): Pipeline; subscribe(...channels: ValueType[]): Pipeline; unsubscribe(...channels: string[]): Pipeline; psubscribe(...patterns: string[]): Pipeline; punsubscribe(...patterns: string[]): Pipeline; publish(channel: string, message: string, callback?: Callback): Pipeline; watch(...keys: KeyType[]): Pipeline; unwatch(callback?: Callback): Pipeline; cluster(...args: ValueType[]): Pipeline; restore(...args: ValueType[]): Pipeline; migrate(...args: ValueType[]): Pipeline; dump(key: KeyType, callback?: Callback): Pipeline; object(subcommand: string, ...args: ValueType[]): Pipeline; client(...args: ValueType[]): Pipeline; eval(script: string, numKeys: number, ...args: ValueType[]): Pipeline; evalsha(scriptSha: string, numKeys: string, ...args: ValueType[]): Pipeline; script(...args: ValueType[]): Pipeline; quit(callback?: Callback): Pipeline; scan(cursor: number | string): Pipeline; scan(cursor: number | string, matchOption: 'match' | 'MATCH', pattern: string): Pipeline; scan(cursor: number | string, countOption: 'count' | 'COUNT', count: number): Pipeline; scan( cursor: number | string, matchOption: 'match' | 'MATCH', pattern: string, countOption: 'count' | 'COUNT', count: number, ): Pipeline; scan( cursor: number | string, countOption: 'count' | 'COUNT', count: number, matchOption: 'match' | 'MATCH', pattern: string, ): Pipeline; sscan(key: KeyType, cursor: number | string, ...args: ValueType[]): Pipeline; hscan(key: KeyType, cursor: number | string, ...args: ValueType[]): Pipeline; zscan(key: KeyType, cursor: number | string, ...args: ValueType[]): Pipeline; pfmerge(destkey: KeyType, ...sourcekeys: KeyType[]): Pipeline; pfadd(key: KeyType, ...elements: string[]): Pipeline; pfcount(...keys: KeyType[]): Pipeline; xack(key: KeyType, group: string, ...ids: string[]): Pipeline; xadd(key: KeyType, id: string, ...args: ValueType[]): Pipeline; xclaim( key: KeyType, group: string, consumer: string, minIdleTime: number, id: string, ...args: ValueType[] ): Pipeline; xdel(key: KeyType, ...ids: string[]): Pipeline; xgroup(...args: ValueType[]): Pipeline; xinfo(...args: ValueType[]): Pipeline; xlen(key: KeyType): Pipeline; xpending(key: KeyType, group: string, ...args: ValueType[]): Pipeline; xrange(key: KeyType, start: string, end: string, ...args: ValueType[]): Pipeline; xread(...args: ValueType[]): Pipeline; xreadgroup(command: 'GROUP' | 'group', group: string, consumer: string, ...args: ValueType[]): Pipeline; xrevrange(key: KeyType, end: string, start: string, ...args: ValueType[]): Pipeline; xtrim(key: KeyType, strategy: 'MAXLEN' | 'maxlen', ...args: ValueType[]): Pipeline; } interface NodeConfiguration { host?: string | undefined; port?: number | undefined; } type ClusterNode = string | number | NodeConfiguration; type NodeRole = 'master' | 'slave' | 'all'; type CallbackFunction = (err?: NodeJS.ErrnoException | null, result?: T) => void; type Ok = 'OK'; interface Cluster extends EventEmitter, Commander, Commands { readonly isCluster: true; readonly options: ClusterOptions; readonly status: string; connect(): Promise; disconnect(reconnect?: boolean): void; duplicate(overrideStartupNodes?: ReadonlyArray, overrideOptions?: ClusterOptions): Cluster; nodes(role?: NodeRole): Redis[]; } interface ClusterStatic extends EventEmitter { new (nodes: ClusterNode[], options?: ClusterOptions): Cluster; } interface RedisOptions { port?: number | undefined; host?: string | undefined; /** * 4 (IPv4) or 6 (IPv6), Defaults to 4. */ family?: number | undefined; /** * Local domain socket path. If set the port, host and family will be ignored. */ path?: string | undefined; /** * TCP KeepAlive on the socket with a X ms delay before start. Set to a non-number value to disable keepAlive. */ keepAlive?: number | undefined; /** * Whether to disable the Nagle's Algorithm. */ noDelay?: boolean | undefined; /** * 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). */ stringNumbers?: boolean | undefined; /** * Default script definition caching time. */ maxScriptsCachingTime?: number | undefined; connectionName?: string | undefined; /** * 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. */ username?: string | undefined; /** * If set, client will send AUTH command with the value of this option when connected. */ password?: string | undefined; /** * Database index to use. */ db?: number | undefined; /** * When a connection is established to the Redis server, the server might still be loading * the database from disk. While loading, the server not respond to any commands. * To work around this, when this option is true, ioredis will check the status of the Redis server, * and when the Redis server is able to process commands, a ready event will be emitted. */ enableReadyCheck?: boolean | undefined; keyPrefix?: string | undefined; /** * When the return value isn't a number, ioredis will stop trying to reconnect. * Fixed in: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/15858 */ retryStrategy?(times: number): number | void | null; /** * By default, all pending commands will be flushed with an error every * 20 retry attempts. That makes sure commands won't wait forever when * the connection is down. You can change this behavior by setting * `maxRetriesPerRequest`. * * Set maxRetriesPerRequest to `null` to disable this behavior, and * every command will wait forever until the connection is alive again * (which is the default behavior before ioredis v4). */ maxRetriesPerRequest?: number | null | undefined; /** * The milliseconds before a timeout occurs when executing a single * command. By default, there is no timeout and the client will wait * indefinitely. The timeout is enforced only on the client side, not * server side. The server may still complete the operation after a * timeout error occurs on the client side. */ commandTimeout?: number | undefined; /** * 1/true means reconnect, 2 means reconnect and resend failed command. Returning false will ignore * the error and do nothing. */ reconnectOnError?(error: Error): boolean | 1 | 2; /** * By default, if there is no active connection to the Redis server, commands are added to a queue * and are executed once the connection is "ready" (when enableReadyCheck is true, "ready" means * the Redis server has loaded the database from disk, otherwise means the connection to the Redis * server has been established). If this option is false, when execute the command when the connection * isn't ready, an error will be returned. */ enableOfflineQueue?: boolean | undefined; /** * The milliseconds before a timeout occurs during the initial connection to the Redis server. * default: 10000. */ connectTimeout?: number | undefined; /** * The milliseconds before socket.destroy() is called after socket.end() if the connection remains half-open during disconnection. * default: 2000 */ disconnectTimeout?: number | undefined; /** * After reconnected, if the previous connection was in the subscriber mode, client will auto re-subscribe these channels. * default: true. */ autoResubscribe?: boolean | undefined; /** * If true, client will resend unfulfilled commands(e.g. block commands) in the previous connection when reconnected. * default: true. */ autoResendUnfulfilledCommands?: boolean | undefined; lazyConnect?: boolean | undefined; tls?: ConnectionOptions | undefined; /** * default: "master". */ role?: 'master' | 'slave' | undefined; /** * default: null. */ name?: string | undefined; sentinelUsername?: string | undefined; sentinelPassword?: string | undefined; sentinels?: Array<{ host: string; port: number }> | undefined; /** * If `sentinelRetryStrategy` returns a valid delay time, ioredis will try to reconnect from scratch. * default: function(times) { return Math.min(times * 10, 1000); } */ sentinelRetryStrategy?(times: number): number | void | null; /** * Can be used to prefer a particular slave or set of slaves based on priority. */ preferredSlaves?: PreferredSlaves | undefined; /** * Whether to support the `tls` option when connecting to Redis via sentinel mode. * default: false. */ enableTLSForSentinelMode?: boolean | undefined; sentinelTLS?: SecureContextOptions | undefined; /** * NAT map for sentinel connector. * default: null. */ natMap?: NatMap | undefined; /** * Update the given `sentinels` list with new IP addresses when communicating with existing sentinels. * default: true. */ updateSentinels?: boolean | undefined; /** * Enable READONLY mode for the connection. Only available for cluster mode. * default: false. */ readOnly?: boolean | undefined; /** * If you are using the hiredis parser, it's highly recommended to enable this option. * Create another instance with dropBufferSupport disabled for other commands that you want to return binary instead of string */ dropBufferSupport?: boolean | undefined; /** * Whether to show a friendly error stack. Will decrease the performance significantly. */ showFriendlyErrorStack?: boolean | undefined; /** * When enabled, all commands issued during an event loop iteration are automatically wrapped in a * pipeline and sent to the server at the same time. This can improve performance by 30-50%. * default: false. */ enableAutoPipelining?: boolean | undefined; } interface AddressFromResponse { port: string; ip: string; flags?: string | undefined; } type PreferredSlaves = | ((slaves: AddressFromResponse[]) => AddressFromResponse | null) | Array<{ port: string; ip: string; prio?: number | undefined }> | { port: string; ip: string; prio?: number | undefined }; type SecureVersion = 'TLSv1.3' | 'TLSv1.2' | 'TLSv1.1' | 'TLSv1'; interface SecureContextOptions { pfx?: string | Buffer | Array | undefined; key?: string | Buffer | Array | undefined; passphrase?: string | undefined; cert?: string | Buffer | Array | undefined; ca?: string | Buffer | Array | undefined; ciphers?: string | undefined; honorCipherOrder?: boolean | undefined; ecdhCurve?: string | undefined; clientCertEngine?: string | undefined; crl?: string | Buffer | Array | undefined; dhparam?: string | Buffer | undefined; secureOptions?: number | undefined; // Value is a numeric bitmask of the `SSL_OP_*` options secureProtocol?: string | undefined; // SSL Method, e.g. SSLv23_method sessionIdContext?: string | undefined; /** * Optionally set the maximum TLS version to allow. One * of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the * `secureProtocol` option, use one or the other. * **Default:** `'TLSv1.3'`, unless changed using CLI options. Using * `--tls-max-v1.2` sets the default to `'TLSv1.2'`. Using `--tls-max-v1.3` sets the default to * `'TLSv1.3'`. If multiple of the options are provided, the highest maximum is used. */ maxVersion?: SecureVersion | undefined; /** * Optionally set the minimum TLS version to allow. One * of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the * `secureProtocol` option, use one or the other. It is not recommended to use * less than TLSv1.2, but it may be required for interoperability. * **Default:** `'TLSv1.2'`, unless changed using CLI options. Using * `--tls-v1.0` sets the default to `'TLSv1'`. Using `--tls-v1.1` sets the default to * `'TLSv1.1'`. Using `--tls-min-v1.3` sets the default to * 'TLSv1.3'. If multiple of the options are provided, the lowest minimum is used. */ minVersion?: SecureVersion | undefined; } interface ScanStreamOption { match?: string | undefined; count?: number | undefined; type?: string | undefined; key?: string | undefined; } type DNSLookupFunction = ( hostname: string, callback: (err: NodeJS.ErrnoException | null, address: string, family?: number) => void, ) => void; interface NatMap { [key: string]: { host: string; port: number }; } interface ClusterOptions { clusterRetryStrategy?(times: number, reason?: Error): number | null; enableOfflineQueue?: boolean | undefined; enableReadyCheck?: boolean | undefined; scaleReads?: string | undefined; maxRedirections?: number | undefined; retryDelayOnFailover?: number | undefined; retryDelayOnClusterDown?: number | undefined; retryDelayOnTryAgain?: number | undefined; slotsRefreshTimeout?: number | undefined; slotsRefreshInterval?: number | undefined; redisOptions?: RedisOptions | undefined; lazyConnect?: boolean | undefined; dnsLookup?: DNSLookupFunction | undefined; natMap?: NatMap | undefined; } interface MultiOptions { pipeline: boolean; } }