declare namespace Redis { interface RetryStrategyOptions { error: NodeJS.ErrnoException; total_retry_time: number; times_connected: number; attempt: number; } type RetryStrategy = (options: RetryStrategyOptions) => number | Error; interface ClientOpts { host?: string; port?: number; path?: string; url?: string; parser?: string; string_numbers?: boolean; return_buffers?: boolean; detect_buffers?: boolean; socket_keepalive?: boolean; no_ready_check?: boolean; enable_offline_queue?: boolean; retry_max_delay?: number; connect_timeout?: number; max_attempts?: number; retry_unfulfilled_commands?: boolean; auth_pass?: string; password?: string; db?: string | number; family?: string; rename_commands?: { [command: string]: string; } | null; tls?: any; prefix?: string; retry_strategy?: RetryStrategy; } type Callback = (err: Error | null, reply: T) => void; interface ServerInfo { redis_version: string; versions: number[]; } interface RedisPromise { /** * Listen for all requests received by the server in real time. */ monitor(): Promise; /** * Get information and statistics about the server. */ info(): Promise; info(section?: string | string[]): Promise; /** * Ping the server. */ ping(): Promise; ping(message: string): Promise; /** * Post a message to a channel. */ publish(channel: string, value: string): Promise; /** * Authenticate to the server. */ auth(password: string): Promise; /** * KILL - Kill the connection of a client. * LIST - Get the list of client connections. * GETNAME - Get the current connection name. * PAUSE - Stop processing commands from clients for some time. * REPLY - Instruct the server whether to reply to commands. * SETNAME - Set the current connection name. */ client(...args: Array): Promise; /** * Set multiple hash fields to multiple values. */ hmset(key: string): Promise; hmset(key: string, ...args: Array): Promise; /** * Listen for messages published to the given channels. */ subscribe(channel: string): Promise; subscribe(channels: string[]): Promise; subscribe(...args: string[]): Promise; /** * Stop listening for messages posted to the given channels. */ unsubscribe(channel: string): Promise; unsubscribe(channels: string[]): Promise; unsubscribe(...args: string[]): Promise; /** * Listen for messages published to channels matching the given patterns. */ psubscribe(channel: string): Promise; psubscribe(channels: string[]): Promise; psubscribe(...args: string[]): Promise; /** * Stop listening for messages posted to channels matching the given patterns. */ punsubscribe(channel: string): Promise; punsubscribe(channels: string[]): Promise; punsubscribe(...args: string[]): Promise; /** * Append a value to a key. */ append(key: string, value: string): Promise; /** * Asynchronously rewrite the append-only file. */ bgrewriteaof(): Promise<'OK'>; /** * Asynchronously save the dataset to disk. */ bgsave(): Promise; /** * Count set bits in a string. */ bitcount(key: string): Promise; bitcount(key: string, start: number, end: number): Promise; /** * Perform arbitrary bitfield integer operations on strings. */ bitfield(): Promise<[number, number]>; bitfield(key: string): Promise<[number, number]>; bitfield(key: string, ...args: Array): Promise<[number, number]>; /** * Perform bitwise operations between strings. */ bitop(operation: string, destKey: string, args: string[]): Promise; /** * Find first bit set or clear in a string. */ bitpos(key: string, bit: number): Promise; bitpos(key: string, bit: number, start: number): Promise; bitpos(key: string, bit: number, start: number, end: number): Promise; /** * Remove and get the first element in a list, or block until one is available. */ blpop(args: Array): Promise<[string, string]>; blpop(...args: Array): Promise<[string, string]>; blpop(arg1: string, arg2: number | Array): Promise<[string, string]>; blpop(arg1: string, arg2: string, arg3: number): Promise<[string, string]>; blpop(arg1: string, arg2: string, arg3: string, arg4: number): Promise<[string, string]>; blpop(arg1: string, arg2: string, arg3: string, arg4: string, arg5: number): Promise<[string, string]>; blpop(arg1: string, arg2: string, arg3: string, arg4: string, arg5: string, arg6: number): Promise<[string, string]>; /** * Remove and get the last element in a list, or block until one is available. */ brpop(args: Array): Promise<[string, string]>; brpop(...args: Array): Promise<[string, string]>; brpop(arg1: string, arg2: number | Array): Promise<[string, string]>; brpop(arg1: string, arg2: string, arg3: number): Promise<[string, string]>; brpop(arg1: string, arg2: string, arg3: string, arg4: number): Promise<[string, string]>; brpop(arg1: string, arg2: string, arg3: string, arg4: string, arg5: number): Promise<[string, string]>; brpop(arg1: string, arg2: string, arg3: string, arg4: string, arg5: string, arg6: number): Promise<[string, string]>; /** * Pop a value from a list, push it to another list and return it; or block until one is available. */ brpoplpush(source: string, destination: string, timeout: number): Promise; /** * ADDSLOTS - Assign new hash slots to receiving node. * COUNT-FAILURE-REPORTS - Return the number of failure reports active for a given node. * COUNTKEYSINSLOT - Return the number of local keys in the specified hash slot. * DELSLOTS - Set hash slots as unbound in receiving node. * FAILOVER - Forces a slave to perform a manual failover of its master. * FORGET - Remove a node from the nodes table. * GETKEYSINSLOT - Return local key names in the specified hash slot. * INFO - Provides info about Redis Cluster node state. * KEYSLOT - Returns the hash slot of the specified key. * MEET - Force a node cluster to handshake with another node. * NODES - Get cluster config for the node. * REPLICATE - Reconfigure a node as a slave of the specified master node. * RESET - Reset a Redis Cluster node. * SAVECONFIG - Forces the node to save cluster state on disk. * SET-CONFIG-EPOCH - Set the configuration epoch in a new node. * SETSLOT - Bind a hash slot to a specified node. * SLAVES - List slave nodes of the specified master node. * SLOTS - Get array of Cluster slot to node mappings. */ cluster(...args: Array): Promise; /** * Get array of Redis command details. * * COUNT - Get total number of Redis commands. * GETKEYS - Extract keys given a full Redis command. * INFO - Get array of specific REdis command details. */ command(): Promise>; /** * Get array of Redis command details. * * COUNT - Get array of Redis command details. * GETKEYS - Extract keys given a full Redis command. * INFO - Get array of specific Redis command details. * GET - Get the value of a configuration parameter. * REWRITE - Rewrite the configuration file with the in memory configuration. * SET - Set a configuration parameter to the given value. * RESETSTAT - Reset the stats returned by INFO. */ config(...args: Array): Promise; /** * Return the number of keys in the selected database. */ dbsize(): Promise; /** * OBJECT - Get debugging information about a key. * SEGFAULT - Make the server crash. */ debug(...args: Array): Promise; /** * Decrement the integer value of a key by one. */ decr(key: string): Promise; /** * Decrement the integer value of a key by the given number. */ decrby(key: string, decrement: number): Promise; /** * Delete a key. */ del(...args: Array): Promise; /** * Discard all commands issued after MULTI. */ discard(): Promise<'OK'>; /** * Return a serialized version of the value stored at the specified key. */ dump(key: string): Promise; /** * Echo the given string. */ echo(message: T): Promise; /** * Execute a Lua script server side. */ eval(...args: Array): Promise; /** * Execute a Lue script server side. */ evalsha(...args: Array): Promise; /** * Determine if a key exists. */ exists(...args: Array): Promise; /** * Set a key's time to live in seconds. */ expire(key: string, seconds: number): Promise; /** * Set the expiration for a key as a UNIX timestamp. */ expireat(key: string, timestamp: number): Promise; /** * Remove all keys from all databases. */ flushall(): Promise; /** * Remove all keys from the current database. */ flushdb(): Promise; /** * Add one or more geospatial items in the geospatial index represented using a sorted set. */ geoadd(): Promise; geoadd(key: string): Promise; geoadd(key: string, ...args: Array): Promise; /** * Returns members of a geospatial index as standard geohash strings. */ geohash(): Promise; geohash(key: string): Promise; geohash(key: string, ...args: Array): Promise; /** * Returns longitude and latitude of members of a geospatial index. */ geopos(): Promise>; geopos(key: string): Promise>; geopos(key: string, ...args: Array): Promise>; /** * Returns the distance between two members of a geospatial index. */ geodist(): Promise; geodist(key: string): Promise; geodist(key: string, ...args: Array): Promise; /** * Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point. */ georadius(): Promise>; georadius(key: string): Promise>; georadius(key: string, ...args: Array): Promise>; /** * Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member. */ georadiusbymember(): Promise>; georadiusbymember(key: string): Promise>; georadiusbymember(key: string, ...args: Array): Promise>; /** * Get the value of a key. */ get(key: string): Promise; /** * Returns the bit value at offset in the string value stored at key. */ getbit(key: string, offset: number): Promise; /** * Get a substring of the string stored at a key. */ getrange(key: string, start: number, end: number): Promise; /** * Set the string value of a key and return its old value. */ getset(key: string, value: string): Promise; hdel(): Promise; hdel(key: string): Promise; hdel(key: string, ...args: Array): Promise; /** * Determine if a hash field exists. */ hexists(key: string, field: string): Promise; /** * Get the value of a hash field. */ hget(key: string, field: string): Promise; /** * Get all fields and values in a hash. */ hgetall(key: string): Promise<{ [key: string]: string; }>; /** * Increment the integer value of a hash field by the given number. */ hincrby(key: string, field: string, increment: number): Promise; /** * Increment the float value of a hash field by the given amount. */ hincrbyfloat(key: string, field: string, increment: number): Promise; /** * Get all the fields of a hash. */ hkeys(key: string): Promise; /** * Get the number of fields in a hash. */ hlen(key: string): Promise; /** * Get the values of all the given hash fields. */ hmget(): Promise; hmget(key: string): Promise; hmget(key: string, ...args: Array): Promise; /** * Set the string value of a hash field. */ hset(key: string, field: string, value: string): Promise; /** * Set the value of a hash field, only if the field does not exist. */ hsetnx(key: string, field: string, value: string): Promise; /** * Get the length of the value of a hash field. */ hstrlen(key: string, field: string): Promise; /** * Get all the values of a hash. */ hvals(key: string): Promise; /** * Increment the integer value of a key by one. */ incr(key: string): Promise; /** * Increment the integer value of a key by the given amount. */ incrby(key: string, increment: number): Promise; /** * Increment the float value of a key by the given amount. */ incrbyfloat(key: string, increment: number): Promise; /** * Find all keys matching the given pattern. */ keys(pattern: string): Promise; /** * Get the UNIX time stamp of the last successful save to disk. */ lastsave(): Promise; /** * Get an element from a list by its index. */ lindex(key: string, index: number): Promise; /** * Insert an element before or after another element in a list. */ linsert(key: string, dir: 'BEFORE' | 'AFTER', pivot: string, value: string): Promise; /** * Get the length of a list. */ llen(key: string): Promise; /** * Remove and get the first element in a list. */ lpop(key: string): Promise; /** * Prepend one or multiple values to a list. */ lpush(): Promise; lpush(key: string): Promise; lpush(key: string, ...args: Array): Promise; /** * Prepend a value to a list, only if the list exists. */ lpushx(key: string, value: string): Promise; /** * Get a range of elements from a list. */ lrange(key: string, start: number, stop: number): Promise; /** * Remove elements from a list. */ lrem(key: string, count: number, value: string): Promise; /** * Set the value of an element in a list by its index. */ lset(key: string, index: number, value: string): Promise<'OK'>; /** * Trim a list to the specified range. */ ltrim(key: string, start: number, stop: number): Promise<'OK'>; /** * Get the values of all given keys. */ mget(...args: Array): Promise; /** * Atomically transfer a key from a Redis instance to another one. */ migrate(...args: Array): Promise; /** * Move a key to another database. */ move(key: string, db: string | number): Promise; /** * Set multiple keys to multiple values. */ mset(...args: Array): Promise; /** * Set multiple keys to multiple values, only if none of the keys exist. */ msetnx(...args: Array): Promise; /** * Inspect the internals of Redis objects. */ object(...args: Array): Promise; /** * Remove the expiration from a key. */ persist(key: string): Promise; /** * Remove a key's time to live in milliseconds. */ pexpire(key: string, milliseconds: number): Promise; /** * Set the expiration for a key as a UNIX timestamp specified in milliseconds. */ pexpireat(key: string, millisecondsTimestamp: number): Promise; /** * Adds the specified elements to the specified HyperLogLog. */ pfadd(): Promise; pfadd(key: string): Promise; pfadd(key: string, ...args: Array): Promise; /** * Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s). */ pfcount(...args: Array): Promise; /** * Merge N different HyperLogLogs into a single one. */ pfmerge(...args: Array): Promise; /** * Set the value and expiration in milliseconds of a key. */ psetex(key: string, milliseconds: number, value: string): Promise<'OK'>; /** * Inspect the state of the Pub/Sub subsystem. */ pubsub(...args: Array): Promise; /** * Get the time to live for a key in milliseconds. */ pttl(key: string): Promise; /** * Close the connection. */ quit(): Promise<'OK'>; /** * Return a random key from the keyspace. */ randomkey(): Promise; /** * Enables read queries for a connection to a cluster slave node. */ readonly(): Promise; /** * Disables read queries for a connection to cluster slave node. */ readwrite(): Promise; /** * Rename a key. */ rename(key: string, newKey: string): Promise<'OK'>; /** * Rename a key, only if the new key does not exist. */ renamenx(key: string, newKey: string): Promise; /** * Create a key using the provided serialized value, previously obtained using DUMP. */ restore(key: string, ttl: number, serializedValue: string): Promise<'OK'>; /** * Return the role of the instance in the context of replication. */ role(): Promise<[string, number, Array<[string, string, string]>]>; /** * Remove and get the last element in a list. */ rpop(key: string): Promise; /** * Remove the last element in a list, prepend it to another list and return it. */ rpoplpush(source: string, destination: string): Promise; /** * Append one or multiple values to a list. */ rpush(): Promise; rpush(key: string): Promise; rpush(key: string, ...args: Array): Promise; /** * Append a value to a list, only if the list exists. */ rpushx(key: string, value: string): Promise; /** * Append one or multiple members to a set. */ sadd(): Promise; sadd(key: string): Promise; sadd(key: string, ...args: Array): Promise; /** * Synchronously save the dataset to disk. */ save(): Promise; /** * Get the number of members in a set. */ scard(key: string): Promise; /** * DEBUG - Set the debug mode for executed scripts. * EXISTS - Check existence of scripts in the script cache. * FLUSH - Remove all scripts from the script cache. * KILL - Kill the script currently in execution. * LOAD - Load the specified Lua script into the script cache. */ script(...args: Array): Promise; /** * Subtract multiple sets. */ sdiff(...args: Array): Promise; /** * Subtract multiple sets and store the resulting set in a key. */ sdiffstore(): Promise; sdiffstore(key: string): Promise; sdiffstore(key: string, ...args: Array): Promise; /** * Change the selected database for the current connection. */ select(index: number | string): Promise; /** * Set the string value of a key. */ set(key: string, value: string): Promise<'OK'>; set(key: string, value: string, flag: string): Promise<'OK'>; set(key: string, value: string, mode: string, duration: number): Promise<'OK' | undefined>; set(key: string, value: string, mode: string, duration: number, flag: string): Promise<'OK' | undefined>; /** * Sets or clears the bit at offset in the string value stored at key. */ setbit(key: string, offset: number, value: string): Promise; /** * Set the value and expiration of a key. */ setex(key: string, seconds: number, value: string): Promise; /** * Set the value of a key, only if the key does not exist. */ setnx(key: string, value: string): Promise; /** * Overwrite part of a string at key starting at the specified offset. */ setrange(key: string, offset: number, value: string): Promise; /** * Synchronously save the dataset to disk and then shut down the server. */ shutdown(...args: Array): Promise; /** * Intersect multiple sets. */ sinter(): Promise; sinter(key: string): Promise; sinter(key: string, ...args: Array): Promise; /** * Intersect multiple sets and store the resulting set in a key. */ sinterstore(...args: Array): Promise; /** * Determine if a given value is a member of a set. */ sismember(key: string, member: string): Promise; /** * Make the server a slave of another instance, or promote it as master. */ slaveof(host: string, port: string | number): Promise; /** * Manages the Redis slow queries log. */ slowlog(...args: Array): Promise>; /** * Get all the members in a set. */ smembers(key: string): Promise; /** * Move a member from one set to another. */ smove(source: string, destination: string, member: string): Promise; /** * Sort the elements in a list, set or sorted set. */ sort(...args: Array): Promise; /** * Remove and return one or multiple random members from a set. */ spop(key: string): Promise; spop(key: string, count: number): Promise; /** * Get one or multiple random members from a set. */ srandmember(key: string): Promise; srandmember(key: string, count: number): Promise; /** * Remove one or more members from a set. */ srem(): Promise; srem(key: string): Promise; srem(key: string, ...args: Array): Promise; /** * Get the length of the value stored in a key. */ strlen(key: string): Promise; /** * Add multiple sets. */ sunion(...args: Array): Promise; /** * Add multiple sets and store the resulting set in a key. */ sunionstore(...args: Array): Promise; /** * Internal command used for replication. */ sync(): Promise; /** * Return the current server time. */ time(): Promise<[string, string]>; /** * Get the time to live for a key. */ ttl(key: string): Promise; /** * Determine the type stored at key. */ type(key: string): Promise; /** * Forget about all watched keys. */ unwatch(): Promise<'OK'>; /** * Wait for the synchronous replication of all the write commands sent in the context of the current connection. */ wait(numSlaves: number, timeout: number): Promise; /** * Watch the given keys to determine execution of the MULTI/EXEC block. */ watch(...args: Array): Promise<'OK'>; /** * Add one or more members to a sorted set, or update its score if it already exists. */ zadd(): Promise; zadd(key: string): Promise; zadd(key: string, ...args: Array): Promise; /** * Get the number of members in a sorted set. */ zcard(key: string): Promise; /** * Count the members in a sorted set with scores between the given values. */ zcount(key: string, min: number | string, max: number | string): Promise; /** * Increment the score of a member in a sorted set. */ zincrby(key: string, increment: number, member: string): Promise; /** * Intersect multiple sorted sets and store the resulting sorted set in a new key. */ zinterstore(...args: Array): Promise; /** * Count the number of members in a sorted set between a given lexicographic range. */ zlexcount(key: string, min: string, max: string): Promise; /** * Return a range of members in a sorted set, by index. */ zrange(key: string, start: number, stop: number): Promise; zrange(key: string, start: number, stop: number, withScores: string): Promise; /** * Return a range of members in a sorted set, by lexicographical range. */ zrangebylex(key: string, min: string, max: string): Promise; zrangebylex(key: string, min: string, max: string, limit: string, offset: number, count: number): Promise; /** * Return a range of members in a sorted set, by lexicographical range, ordered from higher to lower strings. */ zrevrangebylex(key: string, min: string, max: string): Promise; zrevrangebylex(key: string, min: string, max: string, limit: string, offset: number, count: number): Promise; /** * Return a range of members in a sorted set, by score. */ zrangebyscore(key: string, min: number | string, max: number | string): Promise; zrangebyscore(key: string, min: number | string, max: number | string, withScores: string): Promise; zrangebyscore(key: string, min: number | string, max: number | string, limit: string, offset: number, count: number): Promise; zrangebyscore(key: string, min: number | string, max: number | string, withScores: string, limit: string, offset: number, count: number): Promise; /** * Determine the index of a member in a sorted set. */ zrank(key: string, member: string): Promise; /** * Remove one or more members from a sorted set. */ zrem(): Promise; zrem(key: string): Promise; zrem(key: string, ...args: Array): Promise; /** * Remove all members in a sorted set between the given lexicographical range. */ zremrangebylex(key: string, min: string, max: string): Promise; /** * Remove all members in a sorted set within the given indexes. */ zremrangebyrank(key: string, start: number, stop: number): Promise; /** * Remove all members in a sorted set within the given indexes. */ zremrangebyscore(key: string, min: string | number, max: string | number): Promise; /** * Return a range of members in a sorted set, by index, with scores ordered from high to low. */ zrevrange(key: string, start: number, stop: number): Promise; zrevrange(key: string, start: number, stop: number, withScores: string): Promise; /** * Return a range of members in a sorted set, by score, with scores ordered from high to low. */ zrevrangebyscore(key: string, min: number | string, max: number | string): Promise; zrevrangebyscore(key: string, min: number | string, max: number | string, withScores: string): Promise; zrevrangebyscore(key: string, min: number | string, max: number | string, limit: string, offset: number, count: number): Promise; zrevrangebyscore(key: string, min: number | string, max: number | string, withScores: string, limit: string, offset: number, count: number): Promise; /** * Determine the index of a member in a sorted set, with scores ordered from high to low. */ zrevrank(key: string, member: string): Promise; /** * Get the score associated with the given member in a sorted set. */ zscore(key: string, member: string): Promise; /** * Add multiple sorted sets and store the resulting sorted set in a new key. */ zunionstore(...args: Array): Promise; /** * Incrementally iterate the keys space. */ scan(...args: Array): Promise<[string, string[]]>; /** * Incrementally iterate Set elements. */ sscan(): Promise<[string, string[]]>; sscan(key: string): Promise<[string, string[]]>; sscan(key: string, ...args: Array): Promise<[string, string[]]>; /** * Incrementally iterate hash fields and associated values. */ hscan(): Promise<[string, string[]]>; hscan(key: string): Promise<[string, string[]]>; hscan(key: string, ...args: Array): Promise<[string, string[]]>; /** * Incrementally iterate sorted sets elements and associated scores. */ zscan(): Promise<[string, string[]]>; zscan(key: string): Promise<[string, string[]]>; zscan(key: string, ...args: Array): Promise<[string, string[]]>; } }