When connecting to a Redis server that requires authentication, the AUTH command must be sent as the first command after connecting.
When connecting to a Redis server that requires authentication, the AUTH command must be sent as the first command after connecting. This can be tricky to coordinate with reconnections, the ready check, etc. To make this easier, client.auth() stashes password and will send it after each connection, including reconnections. callback is invoked only once, after the response to the very first AUTH command sent. NOTE: Your call to client.auth() should not be inside the ready handler. If you are doing this wrong, client will emit an error that looks something like this Error: Ready check failed: ERR operation not permitted.
the user password
the optional callback
Identical to .multi without transactions.
Identical to .multi without transactions. This is recommended if you want to execute many commands at once but don't have to rely on transactions.
batch([commands])
The number of commands that have been sent to the Redis server but not yet replied to.
The number of commands that have been sent to the Redis server but not yet replied to. You can use this to enforce some kind of maximum queue depth for commands while connected.
Boolean tracking the state of the connection to the Redis server.
Deletes an array of records by their respective keys
Deletes an array of records by their respective keys
the given array of keys
the given callback
Deletes a record by key
Deletes a record by key
the given key
the given callback
Deletes a key
Deletes a key
the given key
Dumps a record by key
Dumps a record by key
the given key
the given callback
Duplicate all current options and return a new redisClient instance.
Duplicate all current options and return a new redisClient instance. All options passed to the duplicate function are going to replace the original option. If you pass a callback, duplicate is going to wait until the client is ready and returns it in the callback. If an error occurs in the meanwhile, that is going to return an error instead in the callback.
the optional settings
the optional callback
Forcibly close the connection to the Redis server.
Forcibly close the connection to the Redis server. Note that this does not wait until all replies have been parsed. If you want to exit cleanly, call client.quit() as mentioned above.
You should set flush to true, if you are not absolutely sure you do not care about any other commands. If you set flush to false all still running commands will silently fail.
indicates whether the want a flush to occur before closing the connection
Indicates whether a key exists
Indicates whether a key exists
the given key
the given callback <Error, Integer>
Indicates whether a key exists
Indicates whether a key exists
the given key
the given callback <Error, Integer>
Most Redis commands take a single String or an Array of Strings as arguments, and replies are sent back as a single String or an Array of Strings.
Most Redis commands take a single String or an Array of Strings as arguments, and replies are sent back as a single String or an Array of Strings. When dealing with hash values, there are a couple of useful exceptions to this.
the given hash key
the callback
client.hmset("hosts", "mjr", "1", "another", "23", "home", "1234"); client.hgetall("hosts", function (err, obj) { console.dir(obj); });
Redis supports the MONITOR command, which lets you see all commands received by the Redis server across all client connections, including from other client libraries and other computers.
Redis supports the MONITOR command, which lets you see all commands received by the Redis server across all client connections, including from other client libraries and other computers.
A monitor event is going to be emitted for every command fired from any client connected to the server including the monitoring client itself. The callback for the monitor event takes a timestamp from the Redis server, an array of command arguments and the raw monitoring string.
the callback
The number of commands that have been queued up for a future connection.
The number of commands that have been queued up for a future connection. You can use this to enforce some kind of maximum queue depth for pre-connection commands.
This sends the quit command to the redis server and ends cleanly right after all running commands were properly handled.
This sends the quit command to the redis server and ends cleanly right after all running commands were properly handled. If this is called while reconnecting (and therefor no connection to the redis server exists) it is going to end the connection right away instead of resulting in further re-connections! All offline commands are going to be flushed with an error in that case.
sadd("bigset", "a member");
script('load', 'return 1')
All Redis commands have been added to the client object.
All Redis commands have been added to the client object. However, if new commands are introduced before this library is updated, you can use send_command() to send arbitrary commands to Redis. The command_name has to be lower case.
All commands are sent as multi-bulk commands. args can either be an Array of arguments, or omitted / set to undefined.
the command name
the optional command arguments
the optional callback
After the ready probe completes, the results from the INFO command are saved in the client.server_info object.
Sets key-value pairs
Sets key-value pairs
the collection of key-value pairs
the callback
client.set(["some other key", "some val"]);
Sets key-value pairs
Sets key-value pairs
the collection of key-value pairs
client.set(["some other key", "some val"]);
Sets a key-value pair
Sets a key-value pair
the given key
the given value
the callback
client.set("some key", "some val");
The client exposed the used stream in client.stream and if the stream or client had to buffer the command in client.should_buffer.
The client exposed the used stream in client.stream and if the stream or client had to buffer the command in client.should_buffer. In combination this can be used to implement backpressure by checking the buffer state before sending a command and listening to the stream drain event.
Redis Client