ReadonlyprotocolThe RESP version in use on this connection.
ReadonlyserverThe server properties from the HELLO handshake; only populated when protocol: 3.
ReadonlysubscriptionHow many channels and patterns the connection is currently subscribed to.
Closes the connection and ends every subscription.
Resolves once the socket is closed.
Decrements a key by one.
The key to decrement.
The value after the decrement.
Deletes keys.
The keys to delete.
How many keys were removed.
Runs a Lua script on the server.
The script source.
Optionalopts: RedisEvalOptions
The script's KEYS and ARGV.
The script's reply.
Runs a Lua script the server has already cached, by its SHA1.
The script's SHA1, as returned by SCRIPT LOAD.
Optionalopts: RedisEvalOptions
The script's KEYS and ARGV.
The script's reply.
Counts how many of the given keys exist.
The keys to test.
The number that exist (counting duplicates separately, as Redis does).
Sets a key's time to live.
The key to expire.
Seconds until expiry.
True if the timeout was set, false if the key does not exist.
Gets a key's value as raw bytes.
The key to read.
The bytes, or null if the key does not exist.
Gets a key's value as UTF-8 text.
The key to read.
The value, or null if the key does not exist.
Deletes hash fields.
The hash key.
The fields to remove.
How many fields were removed.
Gets a hash field as raw bytes.
The hash key.
The field to read.
The bytes, or null if the field or key does not exist.
Reads a whole hash.
Normalizes the RESP2 flat array and the RESP3 map into the same object.
The hash key.
The fields as a string-to-string object; empty if the key does not exist.
Gets a hash field as UTF-8 text.
The hash key.
The field to read.
The value, or null if the field or key does not exist.
Sets one or more hash fields.
The hash key.
Field-to-value pairs to write.
How many fields were newly added.
Increments a key by one.
The key to increment.
The value after the increment.
Increments a key by an integer amount.
The key to increment.
The amount to add (may be negative).
The value after the increment.
Reads the server's INFO report, parsed into fields.
Optionalsection: string
Optional section to limit the report to, e.g. 'memory'.
The report's key:value lines as an object (section headers are dropped).
Lists every key matching a pattern.
KEYS walks the whole keyspace, which blocks the server on a large database; prefer
scanIterator outside of small datasets and one-off tooling.
A glob-style pattern, e.g. 'session:*'.
The matching keys.
Reads a list's length.
The list key.
The number of elements; 0 if the key does not exist.
Removes and returns the first element of a list.
The list key.
The element as text, or null if the list is empty.
Prepends values to a list.
The list key.
The values to prepend.
The list's length afterwards.
Reads a range of a list.
The list key.
First index (0-based; negative counts from the end).
Last index, inclusive (-1 for the final element).
The elements as text.
Gets several keys at once.
The keys to read.
One entry per key, null where the key does not exist.
Sets several keys at once.
Key-to-value pairs to write.
Resolves once the server confirms.
Runs several commands atomically in a MULTI / EXEC transaction.
Like pipeline, a per-command failure surfaces on that reply's RedisReply.error rather than throwing.
The commands to queue, in order.
One reply per command, as returned by EXEC.
Pings the server.
Optionalmessage: string
Optional payload the server echoes back.
'PONG', or the echoed message.
Runs several commands in one round trip and returns their replies in order.
Unlike send, a command that fails does not throw: its reply carries the message on RedisReply.error so one failure does not discard the other results. Reading such a reply's value throws, so a failure cannot be mistaken for data.
The commands to run, in order.
One reply per command.
Subscribes to one or more glob-style channel patterns.
The patterns to subscribe to, e.g. 'news.*'.
The subscription; each delivery carries the matched pattern.
Publishes a message to a channel.
The channel to publish to.
The payload (a string is UTF-8 encoded).
How many subscribers received it.
Publishes a value as JSON to a channel.
The channel to publish to.
The value to serialize and publish.
How many subscribers received it.
Removes and returns the last element of a list.
The list key.
The element as text, or null if the list is empty.
Appends values to a list.
The list key.
The values to append.
The list's length afterwards.
Adds members to a set.
The set key.
The members to add.
How many members were newly added.
Reads one page of the keyspace.
Optionalopts: RedisScanOptions & { cursor?: string }
Cursor and filter options; omit cursor to start a new scan.
The page's keys and the cursor for the next call.
Walks the whole keyspace one page at a time, yielding each key.
Optionalopts: RedisScanOptions
Filter options passed to each underlying SCAN.
An async iterable of keys.
Switches the connection to another database index.
The database index.
Resolves once the server confirms.
Runs one command and returns its reply.
The command name followed by its arguments.
The reply.
Sets a key, optionally with an expiry or an existence condition.
The key to write.
The value (a string is UTF-8 encoded).
Optionalopts: RedisSetOptions
Expiry and NX / XX options.
True if the key was set; false when nx or xx prevented it.
Tests set membership.
The set key.
The member to test.
True if the member is in the set.
Reads every member of a set.
The set key.
The members as text; empty if the key does not exist.
Removes members from a set.
The set key.
The members to remove.
How many members were removed.
Subscribes to one or more channels.
Resolves once the server has confirmed every channel, so a publish issued afterwards is
guaranteed to be delivered. On a protocol: 2 connection this puts the socket into
subscriber mode, where Redis rejects ordinary commands until every subscription is
released; protocol: 3 has no such restriction.
The channels to subscribe to.
The subscription.
Reads a key's remaining time to live.
The key to inspect.
Seconds remaining, -1 if the key has no expiry, -2 if it does not exist.
Adds scored members to a sorted set.
The sorted-set key.
Member-to-score pairs.
How many members were newly added.
Reads a range of a sorted set by rank.
The sorted-set key.
First rank (0-based; negative counts from the end).
Last rank, inclusive (-1 for the last member).
Optionalopts: { rev?: boolean }
Pass rev to order from highest score to lowest.
The members as text, in score order.
Reads a range of a sorted set by rank, with each member's score.
Normalizes the RESP2 flat array and the RESP3 member-score pairs into the same shape.
The sorted-set key.
First rank (0-based; negative counts from the end).
Last rank, inclusive (-1 for the last member).
Optionalopts: { rev?: boolean }
Pass rev to order from highest score to lowest.
The members with their scores, in score order.
Removes members from a sorted set.
The sorted-set key.
The members to remove.
How many members were removed.
A live Redis connection over a single socket.
Obtain one from connect. A background pump reads replies and routes them, so commands, pipelines, and Pub/Sub deliveries can all be in flight at once. It is an
AsyncDisposable, soawait usingcloses it cleanly.send runs any command, which is the escape hatch for everything the typed methods below do not cover (streams, cluster commands, module commands,
CONFIG, ...).Since
1.0.6