title: Redis 8.6 Commands Reference

title: Overview

text:
This page provides a comprehensive reference of all Redis commands available in Redis 8.6, organized by functional group. Each command includes its description and syntax in a collapsible section for easy navigation.

Redis 8.6 includes all commands from previous versions plus new commands introduced in 8.6. Commands marked with **⭐ New in 8.6** were added in this release.

title: Quick Navigation

title: String commands

text:
String commands operate on string values, the most basic Redis data type.

APPEND - Appends a string to the value of a key. Creates the key if it doesn't exist.

**Syntax:** `APPEND key value`

**Description:** Appends a string to the value of a key. Creates the key if it doesn't exist.

**Complexity:** O(1). The amortized time complexity is O(1) assuming the appended value is small and the already present value is of any size, since the dynamic string library used by Redis will double the free space available on every reallocation.

**Since:** 2.0.0

DECR - Decrements the integer value of a key by one. Uses 0 as initial value if the key doesn't exist.

**Syntax:** `DECR key`

**Description:** Decrements the integer value of a key by one. Uses 0 as initial value if the key doesn't exist.

**Complexity:** O(1)

**Since:** 1.0.0

DECRBY - Decrements a number from the integer value of a key. Uses 0 as initial value if the key doesn't exist.

**Syntax:** `DECRBY key decrement`

**Description:** Decrements a number from the integer value of a key. Uses 0 as initial value if the key doesn't exist.

**Complexity:** O(1)

**Since:** 1.0.0

DELEX - Conditionally removes the specified key based on value or hash digest comparison.

**Syntax:** `DELEX key [IFEQ ifeq-value | IFNE ifne-value | IFDEQ ifdeq-digest |
  IFDNE ifdne-digest]`

**Description:** Conditionally removes the specified key based on value or hash digest comparison.

**Complexity:** O(1) for IFEQ/IFNE, O(N) for IFDEQ/IFDNE where N is the length of the string value.

**Since:** 8.4.0

DIGEST - Returns the hash digest of a string value as a hexadecimal string.

**Syntax:** `DIGEST key`

**Description:** Returns the hash digest of a string value as a hexadecimal string.

**Complexity:** O(N) where N is the length of the string value.

**Since:** 8.4.0

GET - Returns the string value of a key.

**Syntax:** `GET key`

**Description:** Returns the string value of a key.

**Complexity:** O(1)

**Since:** 1.0.0

GETDEL - Returns the string value of a key after deleting the key.

**Syntax:** `GETDEL key`

**Description:** Returns the string value of a key after deleting the key.

**Complexity:** O(1)

**Since:** 6.2.0

GETEX - Returns the string value of a key after setting its expiration time.

**Syntax:** `GETEX key [EX seconds | PX milliseconds | EXAT unix-time-seconds |
  PXAT unix-time-milliseconds | PERSIST]`

**Description:** Returns the string value of a key after setting its expiration time.

**Complexity:** O(1)

**Since:** 6.2.0

GETRANGE - Returns a substring of the string stored at a key.

**Syntax:** `GETRANGE key start end`

**Description:** Returns a substring of the string stored at a key.

**Complexity:** O(N) where N is the length of the returned string. The complexity is ultimately determined by the returned length, but because creating a substring from an existing string is very cheap, it can be considered O(1) for small strings.

**Since:** 2.4.0

GETSET - Returns the previous string value of a key after setting it to a new value.

**Syntax:** `GETSET key value`

**Description:** Returns the previous string value of a key after setting it to a new value.

**Complexity:** O(1)

**Since:** 1.0.0

INCR - Increments the integer value of a key by one. Uses 0 as initial value if the key doesn't exist.

**Syntax:** `INCR key`

**Description:** Increments the integer value of a key by one. Uses 0 as initial value if the key doesn't exist.

**Complexity:** O(1)

**Since:** 1.0.0

INCRBY - Increments the integer value of a key by a number. Uses 0 as initial value if the key doesn't exist.

**Syntax:** `INCRBY key increment`

**Description:** Increments the integer value of a key by a number. Uses 0 as initial value if the key doesn't exist.

**Complexity:** O(1)

**Since:** 1.0.0

INCRBYFLOAT - Increment the floating point value of a key by a number. Uses 0 as initial value if the key doesn't exist.

**Syntax:** `INCRBYFLOAT key increment`

**Description:** Increment the floating point value of a key by a number. Uses 0 as initial value if the key doesn't exist.

**Complexity:** O(1)

**Since:** 2.6.0

LCS - Finds the longest common substring.

**Syntax:** `LCS key1 key2 [LEN] [IDX] [MINMATCHLEN min-match-len] [WITHMATCHLEN]`

**Description:** Finds the longest common substring.

**Complexity:** O(N*M) where N and M are the lengths of s1 and s2, respectively

**Since:** 7.0.0

MGET - Atomically returns the string values of one or more keys.

**Syntax:** `MGET key [key ...]`

**Description:** Atomically returns the string values of one or more keys.

**Complexity:** O(N) where N is the number of keys to retrieve.

**Since:** 1.0.0

MSET - Atomically creates or modifies the string values of one or more keys.

**Syntax:** `MSET key value [key value ...]`

**Description:** Atomically creates or modifies the string values of one or more keys.

**Complexity:** O(N) where N is the number of keys to set.

**Since:** 1.0.1

MSETEX - Atomically sets multiple string keys with a shared expiration in a single operation.

**Syntax:** `MSETEX numkeys key value [key value ...] [NX | XX] [EX seconds |
  PX milliseconds | EXAT unix-time-seconds |
  PXAT unix-time-milliseconds | KEEPTTL]`

**Description:** Atomically sets multiple string keys with a shared expiration in a single operation.

**Complexity:** O(N) where N is the number of keys to set.

**Since:** 8.4.0

MSETNX - Atomically modifies the string values of one or more keys only when all keys don't exist.

**Syntax:** `MSETNX key value [key value ...]`

**Description:** Atomically modifies the string values of one or more keys only when all keys don't exist.

**Complexity:** O(N) where N is the number of keys to set.

**Since:** 1.0.1

PSETEX - Sets both string value and expiration time in milliseconds of a key. The key is created if it doesn't exist.

**Syntax:** `PSETEX key milliseconds value`

**Description:** Sets both string value and expiration time in milliseconds of a key. The key is created if it doesn't exist.

**Complexity:** O(1)

**Since:** 2.6.0

SET - Sets the string value of a key, ignoring its type. The key is created if it doesn't exist.

**Syntax:** `SET key value [NX | XX | IFEQ ifeq-value | IFNE ifne-value |
  IFDEQ ifdeq-digest | IFDNE ifdne-digest] [GET] [EX seconds |
  PX milliseconds | EXAT unix-time-seconds |
  PXAT unix-time-milliseconds | KEEPTTL]`

**Description:** Sets the string value of a key, ignoring its type. The key is created if it doesn't exist.

**Complexity:** O(1)

**Since:** 1.0.0

SETEX - Sets the string value and expiration time of a key. Creates the key if it doesn't exist.

**Syntax:** `SETEX key seconds value`

**Description:** Sets the string value and expiration time of a key. Creates the key if it doesn't exist.

**Complexity:** O(1)

**Since:** 2.0.0

SETNX - Set the string value of a key only when the key doesn't exist.

**Syntax:** `SETNX key value`

**Description:** Set the string value of a key only when the key doesn't exist.

**Complexity:** O(1)

**Since:** 1.0.0

SETRANGE - Overwrites a part of a string value with another by an offset. Creates the key if it doesn't exist.

**Syntax:** `SETRANGE key offset value`

**Description:** Overwrites a part of a string value with another by an offset. Creates the key if it doesn't exist.

**Complexity:** O(1), not counting the time taken to copy the new string in place. Usually, this string is very small so the amortized complexity is O(1). Otherwise, complexity is O(M) with M being the length of the value argument.

**Since:** 2.2.0

STRLEN - Returns the length of a string value.

**Syntax:** `STRLEN key`

**Description:** Returns the length of a string value.

**Complexity:** O(1)

**Since:** 2.2.0

SUBSTR - Returns a substring from a string value.

**Syntax:** `SUBSTR key start end`

**Description:** Returns a substring from a string value.

**Complexity:** O(N) where N is the length of the returned string. The complexity is ultimately determined by the returned length, but because creating a substring from an existing string is very cheap, it can be considered O(1) for small strings.

**Since:** 1.0.0

title: Hash commands

text:
Hash commands operate on hash data structures, which map string fields to string values.

HDEL - Deletes one or more fields and their values from a hash. Deletes the hash if no fields remain.

**Syntax:** `HDEL key field [field ...]`

**Description:** Deletes one or more fields and their values from a hash. Deletes the hash if no fields remain.

**Complexity:** O(N) where N is the number of fields to be removed.

**Since:** 2.0.0

HEXISTS - Determines whether a field exists in a hash.

**Syntax:** `HEXISTS key field`

**Description:** Determines whether a field exists in a hash.

**Complexity:** O(1)

**Since:** 2.0.0

HEXPIRE - Set expiry for hash field using relative time to expire (seconds)

**Syntax:** `HEXPIRE key seconds [NX | XX | GT | LT] FIELDS numfields field
  [field ...]`

**Description:** Set expiry for hash field using relative time to expire (seconds)

**Complexity:** O(N) where N is the number of specified fields

**Since:** 7.4.0

HEXPIREAT - Set expiry for hash field using an absolute Unix timestamp (seconds)

**Syntax:** `HEXPIREAT key unix-time-seconds [NX | XX | GT | LT] FIELDS numfields
  field [field ...]`

**Description:** Set expiry for hash field using an absolute Unix timestamp (seconds)

**Complexity:** O(N) where N is the number of specified fields

**Since:** 7.4.0

HEXPIRETIME - Returns the expiration time of a hash field as a Unix timestamp, in seconds.

**Syntax:** `HEXPIRETIME key FIELDS numfields field [field ...]`

**Description:** Returns the expiration time of a hash field as a Unix timestamp, in seconds.

**Complexity:** O(N) where N is the number of specified fields

**Since:** 7.4.0

HGET - Returns the value of a field in a hash.

**Syntax:** `HGET key field`

**Description:** Returns the value of a field in a hash.

**Complexity:** O(1)

**Since:** 2.0.0

HGETALL - Returns all fields and values in a hash.

**Syntax:** `HGETALL key`

**Description:** Returns all fields and values in a hash.

**Complexity:** O(N) where N is the size of the hash.

**Since:** 2.0.0

HGETDEL - Returns the value of a field and deletes it from the hash.

**Syntax:** `HGETDEL key FIELDS numfields field [field ...]`

**Description:** Returns the value of a field and deletes it from the hash.

**Complexity:** O(N) where N is the number of specified fields

**Since:** 8.0.0

HGETEX - Get the value of one or more fields of a given hash key, and optionally set their expiration.

**Syntax:** `HGETEX key [EX seconds | PX milliseconds | EXAT unix-time-seconds |
  PXAT unix-time-milliseconds | PERSIST] FIELDS numfields field
  [field ...]`

**Description:** Get the value of one or more fields of a given hash key, and optionally set their expiration.

**Complexity:** O(N) where N is the number of specified fields

**Since:** 8.0.0

HINCRBY - Increments the integer value of a field in a hash by a number. Uses 0 as initial value if the field doesn't exist.

**Syntax:** `HINCRBY key field increment`

**Description:** Increments the integer value of a field in a hash by a number. Uses 0 as initial value if the field doesn't exist.

**Complexity:** O(1)

**Since:** 2.0.0

HINCRBYFLOAT - Increments the floating point value of a field by a number. Uses 0 as initial value if the field doesn't exist.

**Syntax:** `HINCRBYFLOAT key field increment`

**Description:** Increments the floating point value of a field by a number. Uses 0 as initial value if the field doesn't exist.

**Complexity:** O(1)

**Since:** 2.6.0

HKEYS - Returns all fields in a hash.

**Syntax:** `HKEYS key`

**Description:** Returns all fields in a hash.

**Complexity:** O(N) where N is the size of the hash.

**Since:** 2.0.0

HLEN - Returns the number of fields in a hash.

**Syntax:** `HLEN key`

**Description:** Returns the number of fields in a hash.

**Complexity:** O(1)

**Since:** 2.0.0

HMGET - Returns the values of all fields in a hash.

**Syntax:** `HMGET key field [field ...]`

**Description:** Returns the values of all fields in a hash.

**Complexity:** O(N) where N is the number of fields being requested.

**Since:** 2.0.0

HMSET - Sets the values of multiple fields.

**Syntax:** `HMSET key field value [field value ...]`

**Description:** Sets the values of multiple fields.

**Complexity:** O(N) where N is the number of fields being set.

**Since:** 2.0.0

HPERSIST - Removes the expiration time for each specified field

**Syntax:** `HPERSIST key FIELDS numfields field [field ...]`

**Description:** Removes the expiration time for each specified field

**Complexity:** O(N) where N is the number of specified fields

**Since:** 7.4.0

HPEXPIRE - Set expiry for hash field using relative time to expire (milliseconds)

**Syntax:** `HPEXPIRE key milliseconds [NX | XX | GT | LT] FIELDS numfields field
  [field ...]`

**Description:** Set expiry for hash field using relative time to expire (milliseconds)

**Complexity:** O(N) where N is the number of specified fields

**Since:** 7.4.0

HPEXPIREAT - Set expiry for hash field using an absolute Unix timestamp (milliseconds)

**Syntax:** `HPEXPIREAT key unix-time-milliseconds [NX | XX | GT | LT]
  FIELDS numfields field [field ...]`

**Description:** Set expiry for hash field using an absolute Unix timestamp (milliseconds)

**Complexity:** O(N) where N is the number of specified fields

**Since:** 7.4.0

HPEXPIRETIME - Returns the expiration time of a hash field as a Unix timestamp, in msec.

**Syntax:** `HPEXPIRETIME key FIELDS numfields field [field ...]`

**Description:** Returns the expiration time of a hash field as a Unix timestamp, in msec.

**Complexity:** O(N) where N is the number of specified fields

**Since:** 7.4.0

HPTTL - Returns the TTL in milliseconds of a hash field.

**Syntax:** `HPTTL key FIELDS numfields field [field ...]`

**Description:** Returns the TTL in milliseconds of a hash field.

**Complexity:** O(N) where N is the number of specified fields

**Since:** 7.4.0

HRANDFIELD - Returns one or more random fields from a hash.

**Syntax:** `HRANDFIELD key [count [WITHVALUES]]`

**Description:** Returns one or more random fields from a hash.

**Complexity:** O(N) where N is the number of fields returned

**Since:** 6.2.0

HSCAN - Iterates over fields and values of a hash.

**Syntax:** `HSCAN key cursor [MATCH pattern] [COUNT count] [NOVALUES]`

**Description:** Iterates over fields and values of a hash.

**Complexity:** O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection.

**Since:** 2.8.0

HSET - Creates or modifies the value of a field in a hash.

**Syntax:** `HSET key field value [field value ...]`

**Description:** Creates or modifies the value of a field in a hash.

**Complexity:** O(1) for each field/value pair added, so O(N) to add N field/value pairs when the command is called with multiple field/value pairs.

**Since:** 2.0.0

HSETEX - Set the value of one or more fields of a given hash key, and optionally set their expiration.

**Syntax:** `HSETEX key [FNX | FXX] [EX seconds | PX milliseconds |
  EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL]
  FIELDS numfields field value [field value ...]`

**Description:** Set the value of one or more fields of a given hash key, and optionally set their expiration.

**Complexity:** O(N) where N is the number of fields being set.

**Since:** 8.0.0

HSETNX - Sets the value of a field in a hash only when the field doesn't exist.

**Syntax:** `HSETNX key field value`

**Description:** Sets the value of a field in a hash only when the field doesn't exist.

**Complexity:** O(1)

**Since:** 2.0.0

HSTRLEN - Returns the length of the value of a field.

**Syntax:** `HSTRLEN key field`

**Description:** Returns the length of the value of a field.

**Complexity:** O(1)

**Since:** 3.2.0

HTTL - Returns the TTL in seconds of a hash field.

**Syntax:** `HTTL key FIELDS numfields field [field ...]`

**Description:** Returns the TTL in seconds of a hash field.

**Complexity:** O(N) where N is the number of specified fields

**Since:** 7.4.0

HVALS - Returns all values in a hash.

**Syntax:** `HVALS key`

**Description:** Returns all values in a hash.

**Complexity:** O(N) where N is the size of the hash.

**Since:** 2.0.0

title: List commands

title: Set commands

title: Sorted set commands

title: Stream commands

text:
Stream commands operate on append-only log data structures.

XACK - Returns the number of messages that were successfully acknowledged by the consumer group member of a stream.

**Syntax:** `XACK key group id [id ...]`

**Description:** Returns the number of messages that were successfully acknowledged by the consumer group member of a stream.

**Complexity:** O(1) for each message ID processed.

**Since:** 5.0.0

XACKDEL - Acknowledges and conditionally deletes one or multiple entries for a stream consumer group.

**Syntax:** `XACKDEL key group [KEEPREF | DELREF | ACKED] IDS numids id [id ...]`

**Description:** Acknowledges and conditionally deletes one or multiple entries for a stream consumer group.

**Complexity:** O(1) for each entry ID processed.

**Since:** 8.2.0

XADD - Appends a new message to a stream. Creates the key if it doesn't exist.

**Syntax:** `XADD key [NOMKSTREAM] [KEEPREF | DELREF | ACKED]
  [IDMPAUTO producer-id | IDMP producer-id idempotent-id]
  [<MAXLEN | MINID> [= | ~] threshold [LIMIT count]] <* | id>
  field value [field value ...]`

**Description:** Appends a new message to a stream. Creates the key if it doesn't exist.

**Complexity:** O(1) when adding a new entry, O(N) when trimming where N being the number of entries evicted.

**Since:** 5.0.0

XAUTOCLAIM - Changes, or acquires, ownership of messages in a consumer group, as if the messages were delivered to as consumer group member.

**Syntax:** `XAUTOCLAIM key group consumer min-idle-time start [COUNT count]
  [JUSTID]`

**Description:** Changes, or acquires, ownership of messages in a consumer group, as if the messages were delivered to as consumer group member.

**Complexity:** O(1) if COUNT is small.

**Since:** 6.2.0

XCFGSET - Sets the IDMP configuration parameters for a stream. ⭐ New in 8.6

**Syntax:** `XCFGSET key [IDMP-DURATION duration] [IDMP-MAXSIZE maxsize]`

**Description:** Sets the IDMP configuration parameters for a stream.

**Complexity:** O(1)

**Since:** 8.6.0

XCLAIM - Changes, or acquires, ownership of a message in a consumer group, as if the message was delivered a consumer group member.

**Syntax:** `XCLAIM key group consumer min-idle-time id [id ...] [IDLE ms]
  [TIME unix-time-milliseconds] [RETRYCOUNT count] [FORCE] [JUSTID]
  [LASTID lastid]`

**Description:** Changes, or acquires, ownership of a message in a consumer group, as if the message was delivered a consumer group member.

**Complexity:** O(log N) with N being the number of messages in the PEL of the consumer group.

**Since:** 5.0.0

XDEL - Returns the number of messages after removing them from a stream.

**Syntax:** `XDEL key id [id ...]`

**Description:** Returns the number of messages after removing them from a stream.

**Complexity:** O(1) for each single item to delete in the stream, regardless of the stream size.

**Since:** 5.0.0

XDELEX - Deletes one or multiple entries from the stream.

**Syntax:** `XDELEX key [KEEPREF | DELREF | ACKED] IDS numids id [id ...]`

**Description:** Deletes one or multiple entries from the stream.

**Complexity:** O(1) for each single item to delete in the stream, regardless of the stream size.

**Since:** 8.2.0

XGROUP CREATE - Creates a consumer group.

**Syntax:** `XGROUP CREATE key group <id | $> [MKSTREAM]
  [ENTRIESREAD entries-read]`

**Description:** Creates a consumer group.

**Complexity:** O(1)

**Since:** 5.0.0

XGROUP CREATECONSUMER - Creates a consumer in a consumer group.

**Syntax:** `XGROUP CREATECONSUMER key group consumer`

**Description:** Creates a consumer in a consumer group.

**Complexity:** O(1)

**Since:** 6.2.0

XGROUP DELCONSUMER - Deletes a consumer from a consumer group.

**Syntax:** `XGROUP DELCONSUMER key group consumer`

**Description:** Deletes a consumer from a consumer group.

**Complexity:** O(1)

**Since:** 5.0.0

XGROUP DESTROY - Destroys a consumer group.

**Syntax:** `XGROUP DESTROY key group`

**Description:** Destroys a consumer group.

**Complexity:** O(N) where N is the number of entries in the group's pending entries list (PEL).

**Since:** 5.0.0

XGROUP SETID - Sets the last-delivered ID of a consumer group.

**Syntax:** `XGROUP SETID key group <id | $> [ENTRIESREAD entries-read]`

**Description:** Sets the last-delivered ID of a consumer group.

**Complexity:** O(1)

**Since:** 5.0.0

XINFO CONSUMERS - Returns a list of the consumers in a consumer group.

**Syntax:** `XINFO CONSUMERS key group`

**Description:** Returns a list of the consumers in a consumer group.

**Complexity:** O(1)

**Since:** 5.0.0

XINFO GROUPS - Returns a list of the consumer groups of a stream.

**Syntax:** `XINFO GROUPS key`

**Description:** Returns a list of the consumer groups of a stream.

**Complexity:** O(1)

**Since:** 5.0.0

XINFO STREAM - Returns information about a stream.

**Syntax:** `XINFO STREAM key [FULL [COUNT count]]`

**Description:** Returns information about a stream.

**Complexity:** O(1)

**Since:** 5.0.0

XLEN - Return the number of messages in a stream.

**Syntax:** `XLEN key`

**Description:** Return the number of messages in a stream.

**Complexity:** O(1)

**Since:** 5.0.0

XPENDING - Returns the information and entries from a stream consumer group's pending entries list.

**Syntax:** `XPENDING key group [[IDLE min-idle-time] start end count [consumer]]`

**Description:** Returns the information and entries from a stream consumer group's pending entries list.

**Complexity:** O(N) with N being the number of elements returned, so asking for a small fixed number of entries per call is O(1). O(M), where M is the total number of entries scanned when used with the IDLE filter. When the command returns just the summary and the list of consumers is small, it runs in O(1) time; otherwise, an additional O(N) time for iterating every consumer.

**Since:** 5.0.0

XRANGE - Returns the messages from a stream within a range of IDs.

**Syntax:** `XRANGE key start end [COUNT count]`

**Description:** Returns the messages from a stream within a range of IDs.

**Complexity:** O(N) with N being the number of elements being returned. If N is constant (e.g. always asking for the first 10 elements with COUNT), you can consider it O(1).

**Since:** 5.0.0

XREAD - Returns messages from multiple streams with IDs greater than the ones requested. Blocks until a message is available otherwise.

**Syntax:** `XREAD [COUNT count] [BLOCK milliseconds] STREAMS key [key ...] id
  [id ...]`

**Description:** Returns messages from multiple streams with IDs greater than the ones requested. Blocks until a message is available otherwise.

**Complexity:** For each stream mentioned: O(M) with M being the number of elements returned. If M is constant (for example, always asking for the first 10 elements with COUNT), you can consider it O(1). On the other side when XREADGROUP blocks, XADD will pay the O(N) time in order to serve the N clients blocked on the stream getting new data.

**Since:** 5.0.0

XREADGROUP - Returns new or historical messages from a stream for a consumer in a group. Blocks until a message is available otherwise.

**Syntax:** `XREADGROUP GROUP group consumer [COUNT count] [BLOCK milliseconds]
  [CLAIM min-idle-time] [NOACK] STREAMS key [key ...] id [id ...]`

**Description:** Returns new or historical messages from a stream for a consumer in a group. Blocks until a message is available otherwise.

**Complexity:** For each stream mentioned: O(M) with M being the number of elements returned. If M is constant (e.g. always asking for the first 10 elements with COUNT), you can consider it O(1). On the other side when XREADGROUP blocks, XADD will pay the O(N) time in order to serve the N clients blocked on the stream getting new data.

**Since:** 5.0.0

XREVRANGE - Returns the messages from a stream within a range of IDs in reverse order.

**Syntax:** `XREVRANGE key end start [COUNT count]`

**Description:** Returns the messages from a stream within a range of IDs in reverse order.

**Complexity:** O(N) with N being the number of elements returned. If N is constant (e.g. always asking for the first 10 elements with COUNT), you can consider it O(1).

**Since:** 5.0.0

XSETID - An internal command for replicating stream values.

**Syntax:** `XSETID key last-id [ENTRIESADDED entries-added]
  [MAXDELETEDID max-deleted-id]`

**Description:** An internal command for replicating stream values.

**Complexity:** O(1)

**Since:** 5.0.0

XTRIM - Deletes messages from the beginning of a stream.

**Syntax:** `XTRIM key <MAXLEN | MINID> [= | ~] threshold [LIMIT count] [KEEPREF | DELREF | ACKED]`

**Description:** Deletes messages from the beginning of a stream.

**Complexity:** O(N), with N being the number of evicted entries. Constant times are very small however, since entries are organized in macro nodes containing multiple entries that can be released with a single deallocation.

**Since:** 5.0.0

title: Bitmap commands

text:
Bitmap commands operate on strings as arrays of bits.

BITCOUNT - Counts the number of set bits (population counting) in a string.

**Syntax:** `BITCOUNT key [start end [BYTE | BIT]]`

**Description:** Counts the number of set bits (population counting) in a string.

**Complexity:** O(N)

**Since:** 2.6.0

BITFIELD - Performs arbitrary bitfield integer operations on strings.

**Syntax:** `BITFIELD key [GET encoding offset | [OVERFLOW <WRAP | SAT | FAIL>]
  <SET encoding offset value | INCRBY encoding offset increment>
  [GET encoding offset | [OVERFLOW <WRAP | SAT | FAIL>]
  <SET encoding offset value | INCRBY encoding offset increment>
  ...]]`

**Description:** Performs arbitrary bitfield integer operations on strings.

**Complexity:** O(1) for each subcommand specified

**Since:** 3.2.0

BITFIELD_RO - Performs arbitrary read-only bitfield integer operations on strings.

**Syntax:** `BITFIELD RO key [GET encoding offset [GET encoding offset ...]]`

**Description:** Performs arbitrary read-only bitfield integer operations on strings.

**Complexity:** O(1) for each subcommand specified

**Since:** 6.0.0

BITOP - Performs bitwise operations on multiple strings, and stores the result.

**Syntax:** `BITOP <AND | OR | XOR | NOT | DIFF | DIFF1 | ANDOR | ONE> destkey key [key ...]`

**Description:** Performs bitwise operations on multiple strings, and stores the result.

**Complexity:** O(N)

**Since:** 2.6.0

BITPOS - Finds the first set (1) or clear (0) bit in a string.

**Syntax:** `BITPOS key bit [start [end [BYTE | BIT]]]`

**Description:** Finds the first set (1) or clear (0) bit in a string.

**Complexity:** O(N)

**Since:** 2.8.7

GETBIT - Returns a bit value by offset.

**Syntax:** `GETBIT key offset`

**Description:** Returns a bit value by offset.

**Complexity:** O(1)

**Since:** 2.2.0

SETBIT - Sets or clears the bit at offset of the string value. Creates the key if it doesn't exist.

**Syntax:** `SETBIT key offset value`

**Description:** Sets or clears the bit at offset of the string value. Creates the key if it doesn't exist.

**Complexity:** O(1)

**Since:** 2.2.0

title: HyperLogLog commands

text:
HyperLogLog commands provide probabilistic cardinality estimation.

PFADD - Adds elements to a HyperLogLog key. Creates the key if it doesn't exist.

**Syntax:** `PFADD key [element [element ...]]`

**Description:** Adds elements to a HyperLogLog key. Creates the key if it doesn't exist.

**Complexity:** O(1) to add every element.

**Since:** 2.8.9

PFCOUNT - Returns the approximated cardinality of the set(s) observed by the HyperLogLog key(s).

**Syntax:** `PFCOUNT key [key ...]`

**Description:** Returns the approximated cardinality of the set(s) observed by the HyperLogLog key(s).

**Complexity:** O(1) with a very small average constant time when called with a single key. O(N) with N being the number of keys, and much bigger constant times, when called with multiple keys.

**Since:** 2.8.9

PFDEBUG - Internal commands for debugging HyperLogLog values.

**Syntax:** `PFDEBUG subcommand key`

**Description:** Internal commands for debugging HyperLogLog values.

**Complexity:** N/A

**Since:** 2.8.9

PFMERGE - Merges one or more HyperLogLog values into a single key.

**Syntax:** `PFMERGE destkey [sourcekey [sourcekey ...]]`

**Description:** Merges one or more HyperLogLog values into a single key.

**Complexity:** O(N) to merge N HyperLogLogs, but with high constant times.

**Since:** 2.8.9

PFSELFTEST - An internal command for testing HyperLogLog values.

**Syntax:** `PFSELFTEST`

**Description:** An internal command for testing HyperLogLog values.

**Complexity:** N/A

**Since:** 2.8.9

title: Geospatial commands

title: JSON commands

text:
JSON commands operate on JSON data structures.

JSON.ARRAPPEND - Append one or more json values into the array at path after the last element in it.

**Syntax:** `JSON.ARRAPPEND key [path] value [value ...]`

**Description:** Append one or more json values into the array at path after the last element in it.

**Complexity:** O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.ARRINDEX - Returns the index of the first occurrence of a JSON scalar value in the array at path

**Syntax:** `JSON.ARRINDEX key path value [start [stop]]`

**Description:** Returns the index of the first occurrence of a JSON scalar value in the array at path

**Complexity:** O(N) when path is evaluated to a single value where N is the size of the array, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.ARRINSERT - Inserts the JSON scalar(s) value at the specified index in the array at path

**Syntax:** `JSON.ARRINSERT key path index value [value ...]`

**Description:** Inserts the JSON scalar(s) value at the specified index in the array at path

**Complexity:** O(N) when path is evaluated to a single value where N is the size of the array, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.ARRLEN - Returns the length of the array at path

**Syntax:** `JSON.ARRLEN key [path]`

**Description:** Returns the length of the array at path

**Complexity:** O(1) where path is evaluated to a single value, O(N) where path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.ARRPOP - Removes and returns the element at the specified index in the array at path

**Syntax:** `JSON.ARRPOP key [path [index]]`

**Description:** Removes and returns the element at the specified index in the array at path

**Complexity:** O(N) when path is evaluated to a single value where N is the size of the array and the specified index is not the last element, O(1) when path is evaluated to a single value and the specified index is the last element, or O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.ARRTRIM - Trims the array at path to contain only the specified inclusive range of indices from start to stop

**Syntax:** `JSON.ARRTRIM key path start stop`

**Description:** Trims the array at path to contain only the specified inclusive range of indices from start to stop

**Complexity:** O(N) when path is evaluated to a single value where N is the size of the array, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.CLEAR - Clears all values from an array or an object and sets numeric values to `0`

**Syntax:** `JSON.CLEAR key [path]`

**Description:** Clears all values from an array or an object and sets numeric values to `0`

**Complexity:** O(N) when path is evaluated to a single value where N is the size of the values, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 2.0.0

JSON.DEBUG - Debugging container command

**Syntax:** `JSON.DEBUG`

**Description:** Debugging container command

**Complexity:** N/A

**Since:** 1.0.0

JSON.DEBUG MEMORY - Reports the size in bytes of a key

**Syntax:** `JSON.DEBUG MEMORY key [path]`

**Description:** Reports the size in bytes of a key

**Complexity:** O(N) when path is evaluated to a single value, where N is the size of the value, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.DEL - Deletes a value

**Syntax:** `JSON.DEL key [path]`

**Description:** Deletes a value

**Complexity:** O(N) when path is evaluated to a single value where N is the size of the deleted value, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.FORGET - Deletes a value

**Syntax:** `JSON.FORGET key [path]`

**Description:** Deletes a value

**Complexity:** O(N) when path is evaluated to a single value where N is the size of the deleted value, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.GET - Gets the value at one or more paths in JSON serialized form

**Syntax:** `JSON.GET key [INDENT indent] [NEWLINE newline] [SPACE space] [path
  [path ...]]`

**Description:** Gets the value at one or more paths in JSON serialized form

**Complexity:** O(N) when path is evaluated to a single value where N is the size of the value, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.MERGE - Merges a given JSON value into matching paths. Consequently, JSON values at matching paths are updated, deleted, or expanded with new children

**Syntax:** `JSON.MERGE key path value`

**Description:** Merges a given JSON value into matching paths. Consequently, JSON values at matching paths are updated, deleted, or expanded with new children

**Complexity:** O(M+N) when path is evaluated to a single value where M is the size of the original value (if it exists) and N is the size of the new value, O(M+N) when path is evaluated to multiple values where M is the size of the key and N is the size of the new value * the number of original values in the key

**Since:** 2.6.0

JSON.MGET - Returns the values at a path from one or more keys

**Syntax:** `JSON.MGET key [key ...] path`

**Description:** Returns the values at a path from one or more keys

**Complexity:** O(M*N) when path is evaluated to a single value where M is the number of keys and N is the size of the value, O(N1+N2+...+Nm) when path is evaluated to multiple values where m is the number of keys and Ni is the size of the i-th key

**Since:** 1.0.0

JSON.MSET - Sets or updates the JSON value of one or more keys

**Syntax:** `JSON.MSET key path value [key path value ...]`

**Description:** Sets or updates the JSON value of one or more keys

**Complexity:** O(K*(M+N)) where k is the number of keys in the command, when path is evaluated to a single value where M is the size of the original value (if it exists) and N is the size of the new value, or O(K*(M+N)) when path is evaluated to multiple values where M is the size of the key and N is the size of the new value * the number of original values in the key

**Since:** 2.6.0

JSON.NUMINCRBY - Increments the numeric value at path by a value

**Syntax:** `JSON.NUMINCRBY key path value`

**Description:** Increments the numeric value at path by a value

**Complexity:** O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.NUMMULTBY - Multiplies the numeric value at path by a value

**Syntax:** `JSON.NUMMULTBY key path value`

**Description:** Multiplies the numeric value at path by a value

**Complexity:** O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.OBJKEYS - Returns the JSON keys of the object at path

**Syntax:** `JSON.OBJKEYS key [path]`

**Description:** Returns the JSON keys of the object at path

**Complexity:** O(N) when path is evaluated to a single value, where N is the number of keys in the object, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.OBJLEN - Returns the number of keys of the object at path

**Syntax:** `JSON.OBJLEN key [path]`

**Description:** Returns the number of keys of the object at path

**Complexity:** O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.RESP - Returns the JSON value at path in Redis Serialization Protocol (RESP)

**Syntax:** `JSON.RESP key [path]`

**Description:** Returns the JSON value at path in Redis Serialization Protocol (RESP)

**Complexity:** O(N) when path is evaluated to a single value, where N is the size of the value, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.SET - Sets or updates the JSON value at a path

**Syntax:** `JSON.SET key path value [NX | XX]`

**Description:** Sets or updates the JSON value at a path

**Complexity:** O(M+N) when path is evaluated to a single value where M is the size of the original value (if it exists) and N is the size of the new value, O(M+N) when path is evaluated to multiple values where M is the size of the key and N is the size of the new value * the number of original values in the key

**Since:** 1.0.0

JSON.STRAPPEND - Appends a string to a JSON string value at path

**Syntax:** `JSON.STRAPPEND key [path] value`

**Description:** Appends a string to a JSON string value at path

**Complexity:** O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.STRLEN - Returns the length of the JSON String at path in key

**Syntax:** `JSON.STRLEN key [path]`

**Description:** Returns the length of the JSON String at path in key

**Complexity:** O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

JSON.TOGGLE - Toggles a boolean value

**Syntax:** `JSON.TOGGLE key path`

**Description:** Toggles a boolean value

**Complexity:** O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 2.0.0

JSON.TYPE - Returns the type of the JSON value at path

**Syntax:** `JSON.TYPE key [path]`

**Description:** Returns the type of the JSON value at path

**Complexity:** O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key

**Since:** 1.0.0

title: Search commands

text:
Search commands provide full-text search and secondary indexing.

FT.AGGREGATE - Run a search query on an index and perform aggregate transformations on the results

**Syntax:** `FT.AGGREGATE index query [VERBATIM] [LOAD count field [field ...]]
  [TIMEOUT timeout] [LOAD *] [GROUPBY nargs property [property ...]
  [REDUCE function nargs arg [arg ...] [AS name] [REDUCE function
  nargs arg [arg ...] [AS name] ...]] [GROUPBY nargs property
  [property ...] [REDUCE function nargs arg [arg ...] [AS name]
  [REDUCE function nargs arg [arg ...] [AS name] ...]] ...]]
  [SORTBY nargs [property <ASC | DESC> [property <ASC | DESC> ...]]
  [MAX num]] [APPLY expression AS name [APPLY expression AS name
  ...]] [LIMIT offset num] [FILTER filter] [WITHCURSOR
  [COUNT read size] [MAXIDLE idle time]] [PARAMS nargs name value
  [name value ...]] [DIALECT dialect]`

**Description:** Run a search query on an index and perform aggregate transformations on the results

**Complexity:** O(1)

**Since:** 1.1.0

FT.ALIASADD - Adds an alias to the index

**Syntax:** `FT.ALIASADD alias index`

**Description:** Adds an alias to the index

**Complexity:** O(1)

**Since:** 1.0.0

FT.ALIASDEL - Deletes an alias from the index

**Syntax:** `FT.ALIASDEL alias`

**Description:** Deletes an alias from the index

**Complexity:** O(1)

**Since:** 1.0.0

FT.ALIASUPDATE - Adds or updates an alias to the index

**Syntax:** `FT.ALIASUPDATE alias index`

**Description:** Adds or updates an alias to the index

**Complexity:** O(1)

**Since:** 1.0.0

FT.ALTER - Adds a new field to the index

**Syntax:** `FT.ALTER index [SKIPINITIALSCAN] SCHEMA ADD field options`

**Description:** Adds a new field to the index

**Complexity:** O(N) where N is the number of keys in the keyspace

**Since:** 1.0.0

FT.CONFIG GET - Retrieves runtime configuration options

**Syntax:** `FT.CONFIG GET option`

**Description:** Retrieves runtime configuration options

**Complexity:** O(1)

**Since:** 1.0.0

FT.CONFIG SET - Sets runtime configuration options

**Syntax:** `FT.CONFIG SET option value`

**Description:** Sets runtime configuration options

**Complexity:** O(1)

**Since:** 1.0.0

FT.CREATE - Creates an index with the given spec

**Syntax:** `FT.CREATE index [ON <HASH | JSON>] [PREFIX count prefix [prefix
  ...]] [FILTER filter] [LANGUAGE default lang]
  [LANGUAGE FIELD lang attribute] [SCORE default score]
  [SCORE FIELD score attribute] [PAYLOAD FIELD payload attribute]
  [MAXTEXTFIELDS] [TEMPORARY seconds] [NOOFFSETS] [NOHL] [NOFIELDS]
  [NOFREQS] [STOPWORDS count [stopword [stopword ...]]]
  [SKIPINITIALSCAN] [INDEXALL <ENABLE | DISABLE>] SCHEMA field name [AS alias] <TEXT | TAG |
  NUMERIC | GEO | VECTOR> [WITHSUFFIXTRIE] [INDEXEMPTY]
  [INDEXMISSING] [SORTABLE [UNF]] [NOINDEX] [field name [AS alias]
  <TEXT | TAG | NUMERIC | GEO | VECTOR> [WITHSUFFIXTRIE]
  [INDEXEMPTY] [INDEXMISSING] [SORTABLE [UNF]] [NOINDEX] ...]`

**Description:** Creates an index with the given spec

**Complexity:** O(K) at creation where K is the number of fields, O(N) if scanning the keyspace is triggered, where N is the number of keys in the keyspace

**Since:** 1.0.0

FT.CURSOR DEL - Deletes a cursor

**Syntax:** `FT.CURSOR DEL index cursor id`

**Description:** Deletes a cursor

**Complexity:** O(1)

**Since:** 1.1.0

FT.CURSOR READ - Reads from a cursor

**Syntax:** `FT.CURSOR READ index cursor id [COUNT read size]`

**Description:** Reads from a cursor

**Complexity:** O(1)

**Since:** 1.1.0

FT.DICTADD - Adds terms to a dictionary

**Syntax:** `FT.DICTADD dict term [term ...]`

**Description:** Adds terms to a dictionary

**Complexity:** O(1)

**Since:** 1.4.0

FT.DICTDEL - Deletes terms from a dictionary

**Syntax:** `FT.DICTDEL dict term [term ...]`

**Description:** Deletes terms from a dictionary

**Complexity:** O(1)

**Since:** 1.4.0

FT.DICTDUMP - Dumps all terms in the given dictionary

**Syntax:** `FT.DICTDUMP dict`

**Description:** Dumps all terms in the given dictionary

**Complexity:** O(N), where N is the size of the dictionary

**Since:** 1.4.0

FT.DROPINDEX - Deletes the index

**Syntax:** `FT.DROPINDEX index [DD]`

**Description:** Deletes the index

**Complexity:** O(1) or O(N) if documents are deleted, where N is the number of keys in the keyspace

**Since:** 2.0.0

FT.EXPLAIN - Returns the execution plan for a complex query

**Syntax:** `FT.EXPLAIN index query [DIALECT dialect]`

**Description:** Returns the execution plan for a complex query

**Complexity:** O(1)

**Since:** 1.0.0

FT.EXPLAINCLI - Returns the execution plan for a complex query

**Syntax:** `FT.EXPLAINCLI index query [DIALECT dialect]`

**Description:** Returns the execution plan for a complex query

**Complexity:** O(1)

**Since:** 1.0.0

FT.HYBRID - Performs hybrid search combining text search and vector similarity search

**Syntax:** `FT.HYBRID index
  SEARCH query
    [SCORER scorer]
    [YIELD SCORE AS name]
  VSIM vector field $vector param
    [KNN count K k [EF RUNTIME ef runtime]]
    [RANGE count RADIUS radius [EPSILON epsilon]]
    [YIELD SCORE AS name]
    [FILTER filter]
  [COMBINE RRF count [CONSTANT constant] [WINDOW window] [YIELD SCORE AS name]]
  [COMBINE LINEAR count [[ALPHA alpha] [BETA beta]] [WINDOW window] [YIELD SCORE AS name]]
  [LIMIT offset num]
  [SORTBY count sortby [ASC | DESC]]
  [NOSORT]
  [LOAD count field [field ...]]
  [LOAD *]
  [GROUPBY nargs property [property ...]
  [GROUPBY nargs property [property ...]
    [REDUCE function nargs arg [arg ...] [AS name]
    [REDUCE function nargs arg [arg ...] [AS name] ...]] ...]]
  [APPLY expression AS name [APPLY expression AS name ...]]
  [FILTER filter]
  PARAMS nargs vector param vector blob [name value ...]
  [TIMEOUT timeout]`

**Description:** Performs hybrid search combining text search and vector similarity search

**Complexity:** O(N+M) where N is the complexity of the text search and M is the complexity of the vector search

**Since:** 8.4.0

FT.INFO - Returns information and statistics on the index

**Syntax:** `FT.INFO index`

**Description:** Returns information and statistics on the index

**Complexity:** O(1)

**Since:** 1.0.0

FT.PROFILE - Performs a `FT.SEARCH` or `FT.AGGREGATE` command and collects performance information

**Syntax:** `FT.PROFILE index <SEARCH | AGGREGATE> [LIMITED] QUERY query`

**Description:** Performs a `FT.SEARCH` or `FT.AGGREGATE` command and collects performance information

**Complexity:** O(N)

**Since:** 2.2.0

FT.SEARCH - Searches the index with a textual query, returning either documents or just ids

**Syntax:** `FT.SEARCH index query [NOCONTENT] [VERBATIM] [NOSTOPWORDS]
  [WITHSCORES] [WITHPAYLOADS] [WITHSORTKEYS] [FILTER numeric field
  min max [FILTER numeric field min max ...]] [GEOFILTER geo field
  lon lat radius <m | km | mi | ft> [GEOFILTER geo field lon lat
  radius <m | km | mi | ft> ...]] [INKEYS count key [key ...]]
  [INFIELDS count field [field ...]] [RETURN count identifier
  [AS property] [identifier [AS property] ...]] [SUMMARIZE
  [FIELDS count field [field ...]] [FRAGS num] [LEN fragsize]
  [SEPARATOR separator]] [HIGHLIGHT [FIELDS count field [field ...]]
  [TAGS open close]] [SLOP slop] [TIMEOUT timeout] [INORDER]
  [LANGUAGE language] [EXPANDER expander] [SCORER scorer]
  [EXPLAINSCORE] [PAYLOAD payload] [SORTBY sortby [ASC | DESC]]
  [LIMIT offset num] [PARAMS nargs name value [name value ...]]
  [DIALECT dialect]`

**Description:** Searches the index with a textual query, returning either documents or just ids

**Complexity:** O(N)

**Since:** 1.0.0

FT.SPELLCHECK - Performs spelling correction on a query, returning suggestions for misspelled terms

**Syntax:** `FT.SPELLCHECK index query [DISTANCE distance] [TERMS <INCLUDE |
  EXCLUDE> dictionary [terms [terms ...]]] [DIALECT dialect]`

**Description:** Performs spelling correction on a query, returning suggestions for misspelled terms

**Complexity:** O(1)

**Since:** 1.4.0

FT.SYNDUMP - Dumps the contents of a synonym group

**Syntax:** `FT.SYNDUMP index`

**Description:** Dumps the contents of a synonym group

**Complexity:** O(1)

**Since:** 1.2.0

FT.SYNUPDATE - Creates or updates a synonym group with additional terms

**Syntax:** `FT.SYNUPDATE index synonym group id [SKIPINITIALSCAN] term [term
  ...]`

**Description:** Creates or updates a synonym group with additional terms

**Complexity:** O(1)

**Since:** 1.2.0

FT.TAGVALS - Returns the distinct tags indexed in a Tag field

**Syntax:** `FT.TAGVALS index field name`

**Description:** Returns the distinct tags indexed in a Tag field

**Complexity:** O(N)

**Since:** 1.0.0

FT._LIST - Returns a list of all existing indexes

**Syntax:** `FT. LIST`

**Description:** Returns a list of all existing indexes

**Complexity:** O(1)

**Since:** 2.0.0

title: Time series commands

text:
Time series commands operate on time-series data.

TS.ADD - Append a sample to a time series

**Syntax:** `TS.ADD key timestamp value [RETENTION retentionPeriod]
  [ENCODING <UNCOMPRESSED | COMPRESSED>] [CHUNK SIZE size]
  [ON DUPLICATE <BLOCK | FIRST | LAST | MIN | MAX | SUM>]
  [LABELS label value [label value ...]]`

**Description:** Append a sample to a time series

**Complexity:** O(M) when M is the amount of compaction rules or O(1) with no compaction

**Since:** 1.0.0

TS.ALTER - Update the retention, chunk size, duplicate policy, and labels of an existing time series

**Syntax:** `TS.ALTER key [RETENTION retentionPeriod] [CHUNK SIZE size]
  [DUPLICATE POLICY <BLOCK | FIRST | LAST | MIN | MAX | SUM>] [LABELS label value
  [label value ...]]`

**Description:** Update the retention, chunk size, duplicate policy, and labels of an existing time series

**Complexity:** O(N) where N is the number of labels requested to update

**Since:** 1.0.0

TS.CREATE - Create a new time series

**Syntax:** `TS.CREATE key [RETENTION retentionPeriod] [ENCODING <UNCOMPRESSED |
  COMPRESSED>] [CHUNK SIZE size] [DUPLICATE POLICY <BLOCK | FIRST |
  LAST | MIN | MAX | SUM>] [LABELS label value [label value ...]]`

**Description:** Create a new time series

**Complexity:** O(1)

**Since:** 1.0.0

TS.CREATERULE - Create a compaction rule

**Syntax:** `TS.CREATERULE sourceKey destKey AGGREGATION <AVG | FIRST | LAST |
  MIN | MAX | SUM | RANGE | COUNT | STD.P | STD.S | VAR.P | VAR.S |
  TWA> bucketDuration [alignTimestamp]`

**Description:** Create a compaction rule

**Complexity:** O(1)

**Since:** 1.0.0

TS.DECRBY - Decrease the value of the sample with the maximum existing timestamp, or create a new sample with a value equal to the value of the sample with the maximum existing timestamp with a given decrement

**Syntax:** `TS.DECRBY key value [TIMESTAMP timestamp]
  [RETENTION retentionPeriod] [UNCOMPRESSED] [CHUNK SIZE size]
  [LABELS label value [label value ...]]`

**Description:** Decrease the value of the sample with the maximum existing timestamp, or create a new sample with a value equal to the value of the sample with the maximum existing timestamp with a given decrement

**Complexity:** O(M) when M is the amount of compaction rules or O(1) with no compaction

**Since:** 1.0.0

TS.DEL - Delete all samples between two timestamps for a given time series

**Syntax:** `TS.DEL key from timestamp to timestamp`

**Description:** Delete all samples between two timestamps for a given time series

**Complexity:** O(N) where N is the number of data points that will be removed

**Since:** 1.6.0

TS.DELETERULE - Delete a compaction rule

**Syntax:** `TS.DELETERULE sourceKey destKey`

**Description:** Delete a compaction rule

**Complexity:** O(1)

**Since:** 1.0.0

TS.GET - Get the sample with the highest timestamp from a given time series

**Syntax:** `TS.GET key [LATEST]`

**Description:** Get the sample with the highest timestamp from a given time series

**Complexity:** O(1)

**Since:** 1.0.0

TS.INCRBY - Increase the value of the sample with the maximum existing timestamp, or create a new sample with a value equal to the value of the sample with the maximum existing timestamp with a given increment

**Syntax:** `TS.INCRBY key value [TIMESTAMP timestamp]
  [RETENTION retentionPeriod] [UNCOMPRESSED] [CHUNK SIZE size]
  [LABELS label value [label value ...]]`

**Description:** Increase the value of the sample with the maximum existing timestamp, or create a new sample with a value equal to the value of the sample with the maximum existing timestamp with a given increment

**Complexity:** O(M) when M is the amount of compaction rules or O(1) with no compaction

**Since:** 1.0.0

TS.INFO - Returns information and statistics for a time series

**Syntax:** `TS.INFO key [DEBUG]`

**Description:** Returns information and statistics for a time series

**Complexity:** O(1)

**Since:** 1.0.0

TS.MADD - Append new samples to one or more time series

**Syntax:** `TS.MADD key timestamp value [key timestamp value ...]`

**Description:** Append new samples to one or more time series

**Complexity:** O(N*M) when N is the amount of series updated and M is the amount of compaction rules or O(N) with no compaction

**Since:** 1.0.0

TS.MGET - Get the sample with the highest timestamp from each time series matching a specific filter

**Syntax:** `TS.MGET [LATEST] [WITHLABELS | SELECTED LABELS label1 [label1 ...]]
  FILTER <l=v | l!=v | l= | l!= | l=(v1,v2,...) | l!=(v1,v2,...)
  [l=v | l!=v | l= | l!= | l=(v1,v2,...) | l!=(v1,v2,...) ...]>`

**Description:** Get the sample with the highest timestamp from each time series matching a specific filter

**Complexity:** O(n) where n is the number of time-series that match the filters

**Since:** 1.0.0

TS.MRANGE - Query a range across multiple time series by filters in forward direction

**Syntax:** `TS.MRANGE fromTimestamp toTimestamp [LATEST] [FILTER BY TS Timestamp
  [Timestamp ...]] [FILTER BY VALUE min max] [WITHLABELS |
  SELECTED LABELS label1 [label1 ...]] [COUNT count] [[ALIGN value]
  AGGREGATION <AVG | FIRST | LAST | MIN | MAX | SUM | RANGE | COUNT
  | STD.P | STD.S | VAR.P | VAR.S | TWA> bucketDuration
  [BUCKETTIMESTAMP] [EMPTY]] FILTER <l=v | l!=v | l= | l!= |
  l=(v1,v2,...) | l!=(v1,v2,...) [l=v | l!=v | l= | l!= |
  l=(v1,v2,...) | l!=(v1,v2,...) ...]> [GROUPBY label REDUCE
  reducer]`

**Description:** Query a range across multiple time series by filters in forward direction

**Complexity:** O(n/m+k) where n = Number of data points, m = Chunk size (data points per chunk), k = Number of data points that are in the requested ranges

**Since:** 1.0.0

TS.MREVRANGE - Query a range across multiple time-series by filters in reverse direction

**Syntax:** `TS.MREVRANGE fromTimestamp toTimestamp [LATEST]
  [FILTER BY TS Timestamp [Timestamp ...]] [FILTER BY VALUE min max]
  [WITHLABELS | SELECTED LABELS label1 [label1 ...]] [COUNT count]
  [[ALIGN value] AGGREGATION <AVG | FIRST | LAST | MIN | MAX | SUM |
  RANGE | COUNT | STD.P | STD.S | VAR.P | VAR.S | TWA>
  bucketDuration [BUCKETTIMESTAMP] [EMPTY]] FILTER <l=v | l!=v | l=
  | l!= | l=(v1,v2,...) | l!=(v1,v2,...) [l=v | l!=v | l= | l!= |
  l=(v1,v2,...) | l!=(v1,v2,...) ...]> [GROUPBY label REDUCE
  reducer]`

**Description:** Query a range across multiple time-series by filters in reverse direction

**Complexity:** O(n/m+k) where n = Number of data points, m = Chunk size (data points per chunk), k = Number of data points that are in the requested ranges

**Since:** 1.4.0

TS.QUERYINDEX - Get all time series keys matching a filter list

**Syntax:** `TS.QUERYINDEX <l=v | l!=v | l= | l!= | l=(v1,v2,...) |
  l!=(v1,v2,...) [l=v | l!=v | l= | l!= | l=(v1,v2,...) |
  l!=(v1,v2,...) ...]>`

**Description:** Get all time series keys matching a filter list

**Complexity:** O(n) where n is the number of time-series that match the filters

**Since:** 1.0.0

TS.RANGE - Query a range in forward direction

**Syntax:** `TS.RANGE key fromTimestamp toTimestamp [LATEST]
  [FILTER BY TS Timestamp [Timestamp ...]] [FILTER BY VALUE min max]
  [COUNT count] [[ALIGN value] AGGREGATION <AVG | FIRST | LAST | MIN
  | MAX | SUM | RANGE | COUNT | STD.P | STD.S | VAR.P | VAR.S | TWA>
  bucketDuration [BUCKETTIMESTAMP] [EMPTY]]`

**Description:** Query a range in forward direction

**Complexity:** O(n/m+k) where n = Number of data points, m = Chunk size (data points per chunk), k = Number of data points that are in the requested range

**Since:** 1.0.0

TS.REVRANGE - Query a range in reverse direction

**Syntax:** `TS.REVRANGE key fromTimestamp toTimestamp [LATEST]
  [FILTER BY TS Timestamp [Timestamp ...]] [FILTER BY VALUE min max]
  [COUNT count] [[ALIGN value] AGGREGATION <AVG | FIRST | LAST | MIN
  | MAX | SUM | RANGE | COUNT | STD.P | STD.S | VAR.P | VAR.S | TWA>
  bucketDuration [BUCKETTIMESTAMP] [EMPTY]]`

**Description:** Query a range in reverse direction

**Complexity:** O(n/m+k) where n = Number of data points, m = Chunk size (data points per chunk), k = Number of data points that are in the requested range

**Since:** 1.4.0

title: Vector set commands

text:
Vector set commands operate on vector data structures for similarity search and range queries.

VADD - Add a new element to a vector set, or update its vector if it already exists.

**Syntax:** `VADD key [REDUCE dim] (FP32 | VALUES num) vector element [CAS] [NOQUANT | Q8 | BIN]
  [EF build-exploration-factor] [SETATTR attributes] [M numlinks]`

**Description:** Add a new element to a vector set, or update its vector if it already exists.

**Complexity:** O(log(N)) for each element added, where N is the number of elements in the vector set.

**Since:** 8.0.0

VCARD - Return the number of elements in a vector set.

**Syntax:** `VCARD key`

**Description:** Return the number of elements in a vector set.

**Complexity:** O(1)

**Since:** 8.0.0

VDIM - Return the dimension of vectors in the vector set.

**Syntax:** `VDIM key`

**Description:** Return the dimension of vectors in the vector set.

**Complexity:** O(1)

**Since:** 8.0.0

VEMB - Return the vector associated with an element.

**Syntax:** `VEMB key element [RAW]`

**Description:** Return the vector associated with an element.

**Complexity:** O(1)

**Since:** 8.0.0

VGETATTR - Retrieve the JSON attributes of elements.

**Syntax:** `VGETATTR key element`

**Description:** Retrieve the JSON attributes of elements.

**Complexity:** O(1)

**Since:** 8.0.0

VINFO - Return information about a vector set.

**Syntax:** `VINFO key`

**Description:** Return information about a vector set.

**Complexity:** O(1)

**Since:** 8.0.0

VISMEMBER - Check if an element exists in a vector set.

**Syntax:** `VISMEMBER key element`

**Description:** Check if an element exists in a vector set.

**Complexity:** O(1)

**Since:** 8.0.0

VLINKS - Return the neighbors of an element at each layer in the HNSW graph.

**Syntax:** `VLINKS key element [WITHSCORES]`

**Description:** Return the neighbors of an element at each layer in the HNSW graph.

**Complexity:** O(1)

**Since:** 8.0.0

VRANDMEMBER - Return one or multiple random members from a vector set.

**Syntax:** `VRANDMEMBER key [count]`

**Description:** Return one or multiple random members from a vector set.

**Complexity:** O(N) where N is the absolute value of the count argument.

**Since:** 8.0.0

VRANGE - Return elements in a lexicographical range

**Syntax:** `VRANGE key start end [count]`

**Description:** Return elements in a lexicographical range

**Complexity:** O(log(K)+M) where K is the number of elements in the start prefix, and M is the number of elements returned. In practical terms, the command is just O(M)

**Since:** 8.4.0

VREM - Remove an element from a vector set.

**Syntax:** `VREM key element`

**Description:** Remove an element from a vector set.

**Complexity:** O(log(N)) for each element removed, where N is the number of elements in the vector set.

**Since:** 8.0.0

VSETATTR - Associate or remove the JSON attributes of elements.

**Syntax:** `VSETATTR key element "{ JSON obj }"`

**Description:** Associate or remove the JSON attributes of elements.

**Complexity:** O(1)

**Since:** 8.0.0

VSIM - Return elements by vector similarity.

**Syntax:** `VSIM key (ELE | FP32 | VALUES num) (vector | element) [WITHSCORES] [WITHATTRIBS] [COUNT num]
  [EPSILON delta] [EF search-exploration-factor] [FILTER expression] [FILTER-EF max-filtering-effort]
  [TRUTH] [NOTHREAD]`

**Description:** Return elements by vector similarity.

**Complexity:** O(log(N)) where N is the number of elements in the vector set.

**Since:** 8.0.0

title: Pub/Sub commands

title: Transaction commands

text:
Transaction commands enable atomic execution of command groups.

DISCARD - Discards a transaction.

**Syntax:** `DISCARD`

**Description:** Discards a transaction.

**Complexity:** O(N), when N is the number of queued commands

**Since:** 2.0.0

EXEC - Executes all commands in a transaction.

**Syntax:** `EXEC`

**Description:** Executes all commands in a transaction.

**Complexity:** Depends on commands in the transaction

**Since:** 1.2.0

MULTI - Starts a transaction.

**Syntax:** `MULTI`

**Description:** Starts a transaction.

**Complexity:** O(1)

**Since:** 1.2.0

UNWATCH - Forgets about watched keys of a transaction.

**Syntax:** `UNWATCH`

**Description:** Forgets about watched keys of a transaction.

**Complexity:** O(1)

**Since:** 2.2.0

WATCH - Monitors changes to keys to determine the execution of a transaction.

**Syntax:** `WATCH key [key ...]`

**Description:** Monitors changes to keys to determine the execution of a transaction.

**Complexity:** O(1) for every key.

**Since:** 2.2.0

title: Scripting commands

title: Connection commands

text:
Connection commands manage client connections.

AUTH - Authenticates the connection.

**Syntax:** `AUTH [username] password`

**Description:** Authenticates the connection.

**Complexity:** O(N) where N is the number of passwords defined for the user

**Since:** 1.0.0

CLIENT CACHING - Instructs the server whether to track the keys in the next request.

**Syntax:** `CLIENT CACHING <YES | NO>`

**Description:** Instructs the server whether to track the keys in the next request.

**Complexity:** O(1)

**Since:** 6.0.0

CLIENT GETNAME - Returns the name of the connection.

**Syntax:** `CLIENT GETNAME`

**Description:** Returns the name of the connection.

**Complexity:** O(1)

**Since:** 2.6.9

CLIENT GETREDIR - Returns the client ID to which the connection's tracking notifications are redirected.

**Syntax:** `CLIENT GETREDIR`

**Description:** Returns the client ID to which the connection's tracking notifications are redirected.

**Complexity:** O(1)

**Since:** 6.0.0

CLIENT ID - Returns the unique client ID of the connection.

**Syntax:** `CLIENT ID`

**Description:** Returns the unique client ID of the connection.

**Complexity:** O(1)

**Since:** 5.0.0

CLIENT INFO - Returns information about the connection.

**Syntax:** `CLIENT INFO`

**Description:** Returns information about the connection.

**Complexity:** O(1)

**Since:** 6.2.0

CLIENT KILL - Terminates open connections.

**Syntax:** `CLIENT KILL <ip:port | <[ID client-id] | [TYPE <NORMAL | MASTER |
  SLAVE | REPLICA | PUBSUB>] | [USER username] | [ADDR ip:port] |
  [LADDR ip:port] | [SKIPME <YES | NO>] | [MAXAGE maxage]
  [[ID client-id] | [TYPE <NORMAL | MASTER | SLAVE | REPLICA |
  PUBSUB>] | [USER username] | [ADDR ip:port] | [LADDR ip:port] |
  [SKIPME <YES | NO>] | [MAXAGE maxage] ...]>>`

**Description:** Terminates open connections.

**Complexity:** O(N) where N is the number of client connections

**Since:** 2.4.0

CLIENT LIST - Lists open connections.

**Syntax:** `CLIENT LIST [TYPE <NORMAL | MASTER | REPLICA | PUBSUB>]
  [ID client-id [client-id ...]]`

**Description:** Lists open connections.

**Complexity:** O(N) where N is the number of client connections

**Since:** 2.4.0

CLIENT NO-EVICT - Sets the client eviction mode of the connection.

**Syntax:** `CLIENT NO-EVICT <ON | OFF>`

**Description:** Sets the client eviction mode of the connection.

**Complexity:** O(1)

**Since:** 7.0.0

CLIENT NO-TOUCH - Controls whether commands sent by the client affect the LRU/LFU of accessed keys.

**Syntax:** `CLIENT NO-TOUCH <ON | OFF>`

**Description:** Controls whether commands sent by the client affect the LRU/LFU of accessed keys.

**Complexity:** O(1)

**Since:** 7.2.0

CLIENT PAUSE - Suspends commands processing.

**Syntax:** `CLIENT PAUSE timeout [WRITE | ALL]`

**Description:** Suspends commands processing.

**Complexity:** O(1)

**Since:** 3.0.0

CLIENT REPLY - Instructs the server whether to reply to commands.

**Syntax:** `CLIENT REPLY <ON | OFF | SKIP>`

**Description:** Instructs the server whether to reply to commands.

**Complexity:** O(1)

**Since:** 3.2.0

CLIENT SETINFO - Sets information specific to the client or connection.

**Syntax:** `CLIENT SETINFO <LIB-NAME libname | LIB-VER libver>`

**Description:** Sets information specific to the client or connection.

**Complexity:** O(1)

**Since:** 7.2.0

CLIENT SETNAME - Sets the connection name.

**Syntax:** `CLIENT SETNAME connection-name`

**Description:** Sets the connection name.

**Complexity:** O(1)

**Since:** 2.6.9

CLIENT TRACKING - Controls server-assisted client-side caching for the connection.

**Syntax:** `CLIENT TRACKING <ON | OFF> [REDIRECT client-id] [PREFIX prefix
  [PREFIX prefix ...]] [BCAST] [OPTIN] [OPTOUT] [NOLOOP]`

**Description:** Controls server-assisted client-side caching for the connection.

**Complexity:** O(1). Some options may introduce additional complexity.

**Since:** 6.0.0

CLIENT TRACKINGINFO - Returns information about server-assisted client-side caching for the connection.

**Syntax:** `CLIENT TRACKINGINFO`

**Description:** Returns information about server-assisted client-side caching for the connection.

**Complexity:** O(1)

**Since:** 6.2.0

CLIENT UNBLOCK - Unblocks a client blocked by a blocking command from a different connection.

**Syntax:** `CLIENT UNBLOCK client-id [TIMEOUT | ERROR]`

**Description:** Unblocks a client blocked by a blocking command from a different connection.

**Complexity:** O(log N) where N is the number of client connections

**Since:** 5.0.0

CLIENT UNPAUSE - Resumes processing commands from paused clients.

**Syntax:** `CLIENT UNPAUSE`

**Description:** Resumes processing commands from paused clients.

**Complexity:** O(N) Where N is the number of paused clients

**Since:** 6.2.0

ECHO - Returns the given string.

**Syntax:** `ECHO message`

**Description:** Returns the given string.

**Complexity:** O(1)

**Since:** 1.0.0

HELLO - Handshakes with the Redis server.

**Syntax:** `HELLO [protover [AUTH username password] [SETNAME clientname]]`

**Description:** Handshakes with the Redis server.

**Complexity:** O(1)

**Since:** 6.0.0

PING - Returns the server's liveliness response.

**Syntax:** `PING [message]`

**Description:** Returns the server's liveliness response.

**Complexity:** O(1)

**Since:** 1.0.0

QUIT - Closes the connection.

**Syntax:** `QUIT`

**Description:** Closes the connection.

**Complexity:** O(1)

**Since:** 1.0.0

RESET - Resets the connection.

**Syntax:** `RESET`

**Description:** Resets the connection.

**Complexity:** O(1)

**Since:** 6.2.0

SELECT - Changes the selected database.

**Syntax:** `SELECT index`

**Description:** Changes the selected database.

**Complexity:** O(1)

**Since:** 1.0.0

title: Server commands

text:
Server commands provide server management and introspection.

ACL CAT - Lists the ACL categories, or the commands inside a category.

**Syntax:** `ACL CAT [category]`

**Description:** Lists the ACL categories, or the commands inside a category.

**Complexity:** O(1) since the categories and commands are a fixed set.

**Since:** 6.0.0

ACL DELUSER - Deletes ACL users, and terminates their connections.

**Syntax:** `ACL DELUSER username [username ...]`

**Description:** Deletes ACL users, and terminates their connections.

**Complexity:** O(1) amortized time considering the typical user.

**Since:** 6.0.0

ACL DRYRUN - Simulates the execution of a command by a user, without executing the command.

**Syntax:** `ACL DRYRUN username command [arg [arg ...]]`

**Description:** Simulates the execution of a command by a user, without executing the command.

**Complexity:** O(1).

**Since:** 7.0.0

ACL GENPASS - Generates a pseudorandom, secure password that can be used to identify ACL users.

**Syntax:** `ACL GENPASS [bits]`

**Description:** Generates a pseudorandom, secure password that can be used to identify ACL users.

**Complexity:** O(1)

**Since:** 6.0.0

ACL GETUSER - Lists the ACL rules of a user.

**Syntax:** `ACL GETUSER username`

**Description:** Lists the ACL rules of a user.

**Complexity:** O(N). Where N is the number of password, command and pattern rules that the user has.

**Since:** 6.0.0

ACL LIST - Dumps the effective rules in ACL file format.

**Syntax:** `ACL LIST`

**Description:** Dumps the effective rules in ACL file format.

**Complexity:** O(N). Where N is the number of configured users.

**Since:** 6.0.0

ACL LOAD - Reloads the rules from the configured ACL file.

**Syntax:** `ACL LOAD`

**Description:** Reloads the rules from the configured ACL file.

**Complexity:** O(N). Where N is the number of configured users.

**Since:** 6.0.0

ACL LOG - Lists recent security events generated due to ACL rules.

**Syntax:** `ACL LOG [count | RESET]`

**Description:** Lists recent security events generated due to ACL rules.

**Complexity:** O(N) with N being the number of entries shown.

**Since:** 6.0.0

ACL SAVE - Saves the effective ACL rules in the configured ACL file.

**Syntax:** `ACL SAVE`

**Description:** Saves the effective ACL rules in the configured ACL file.

**Complexity:** O(N). Where N is the number of configured users.

**Since:** 6.0.0

ACL SETUSER - Creates and modifies an ACL user and its rules.

**Syntax:** `ACL SETUSER username [rule [rule ...]]`

**Description:** Creates and modifies an ACL user and its rules.

**Complexity:** O(N). Where N is the number of rules provided.

**Since:** 6.0.0

ACL USERS - Lists all ACL users.

**Syntax:** `ACL USERS`

**Description:** Lists all ACL users.

**Complexity:** O(N). Where N is the number of configured users.

**Since:** 6.0.0

ACL WHOAMI - Returns the authenticated username of the current connection.

**Syntax:** `ACL WHOAMI`

**Description:** Returns the authenticated username of the current connection.

**Complexity:** O(1)

**Since:** 6.0.0

BGREWRITEAOF - Asynchronously rewrites the append-only file to disk.

**Syntax:** `BGREWRITEAOF`

**Description:** Asynchronously rewrites the append-only file to disk.

**Complexity:** O(1)

**Since:** 1.0.0

BGSAVE - Asynchronously saves the database(s) to disk.

**Syntax:** `BGSAVE [SCHEDULE]`

**Description:** Asynchronously saves the database(s) to disk.

**Complexity:** O(1)

**Since:** 1.0.0

COMMAND - Returns detailed information about all commands.

**Syntax:** `COMMAND`

**Description:** Returns detailed information about all commands.

**Complexity:** O(N) where N is the total number of Redis commands

**Since:** 2.8.13

COMMAND COUNT - Returns a count of commands.

**Syntax:** `COMMAND COUNT`

**Description:** Returns a count of commands.

**Complexity:** O(1)

**Since:** 2.8.13

COMMAND DOCS - Returns documentary information about one, multiple or all commands.

**Syntax:** `COMMAND DOCS [command-name [command-name ...]]`

**Description:** Returns documentary information about one, multiple or all commands.

**Complexity:** O(N) where N is the number of commands to look up

**Since:** 7.0.0

COMMAND GETKEYS - Extracts the key names from an arbitrary command.

**Syntax:** `COMMAND GETKEYS command [arg [arg ...]]`

**Description:** Extracts the key names from an arbitrary command.

**Complexity:** O(N) where N is the number of arguments to the command

**Since:** 2.8.13

COMMAND GETKEYSANDFLAGS - Extracts the key names and access flags for an arbitrary command.

**Syntax:** `COMMAND GETKEYSANDFLAGS command [arg [arg ...]]`

**Description:** Extracts the key names and access flags for an arbitrary command.

**Complexity:** O(N) where N is the number of arguments to the command

**Since:** 7.0.0

COMMAND INFO - Returns information about one, multiple or all commands.

**Syntax:** `COMMAND INFO [command-name [command-name ...]]`

**Description:** Returns information about one, multiple or all commands.

**Complexity:** O(N) where N is the number of commands to look up

**Since:** 2.8.13

COMMAND LIST - Returns a list of command names.

**Syntax:** `COMMAND LIST [FILTERBY <MODULE module-name | ACLCAT category |
  PATTERN pattern>]`

**Description:** Returns a list of command names.

**Complexity:** O(N) where N is the total number of Redis commands

**Since:** 7.0.0

CONFIG GET - Returns the effective values of configuration parameters.

**Syntax:** `CONFIG GET parameter [parameter ...]`

**Description:** Returns the effective values of configuration parameters.

**Complexity:** O(N) when N is the number of configuration parameters provided

**Since:** 2.0.0

CONFIG RESETSTAT - Resets the server's statistics.

**Syntax:** `CONFIG RESETSTAT`

**Description:** Resets the server's statistics.

**Complexity:** O(1)

**Since:** 2.0.0

CONFIG REWRITE - Persists the effective configuration to file.

**Syntax:** `CONFIG REWRITE`

**Description:** Persists the effective configuration to file.

**Complexity:** O(1)

**Since:** 2.8.0

CONFIG SET - Sets configuration parameters in-flight.

**Syntax:** `CONFIG SET parameter value [parameter value ...]`

**Description:** Sets configuration parameters in-flight.

**Complexity:** O(N) when N is the number of configuration parameters provided

**Since:** 2.0.0

DBSIZE - Returns the number of keys in the database.

**Syntax:** `DBSIZE`

**Description:** Returns the number of keys in the database.

**Complexity:** O(1)

**Since:** 1.0.0

FAILOVER - Starts a coordinated failover from a server to one of its replicas.

**Syntax:** `FAILOVER [TO host port [FORCE]] [ABORT] [TIMEOUT milliseconds]`

**Description:** Starts a coordinated failover from a server to one of its replicas.

**Complexity:** O(1)

**Since:** 6.2.0

FLUSHALL - Removes all keys from all databases.

**Syntax:** `FLUSHALL [ASYNC | SYNC]`

**Description:** Removes all keys from all databases.

**Complexity:** O(N) where N is the total number of keys in all databases

**Since:** 1.0.0

FLUSHDB - Remove all keys from the current database.

**Syntax:** `FLUSHDB [ASYNC | SYNC]`

**Description:** Remove all keys from the current database.

**Complexity:** O(N) where N is the number of keys in the selected database

**Since:** 1.0.0

HOTKEYS - A container for hotkeys tracking commands. ⭐ New in 8.6

**Syntax:** `HOTKEYS`

**Description:** A container for hotkeys tracking commands.

**Complexity:** Depends on subcommand.

**Since:** 8.6.0

HOTKEYS GET - Returns lists of top K hotkeys depending on metrics chosen in HOTKEYS START command. ⭐ New in 8.6

**Syntax:** `HOTKEYS GET`

**Description:** Returns lists of top K hotkeys depending on metrics chosen in HOTKEYS START command.

**Complexity:** O(K) where K is the number of hotkeys returned.

**Since:** 8.6.0

HOTKEYS RESET - Release the resources used for hotkey tracking. ⭐ New in 8.6

**Syntax:** `HOTKEYS RESET`

**Description:** Release the resources used for hotkey tracking.

**Complexity:** O(1)

**Since:** 8.6.0

HOTKEYS START - Starts hotkeys tracking. ⭐ New in 8.6

**Syntax:** `HOTKEYS START METRICS count [CPU] [NET] [COUNT k] [DURATION seconds] [SAMPLE ratio] [SLOTS count slot [slot ...]]`

**Description:** Starts hotkeys tracking.

**Complexity:** O(1)

**Since:** 8.6.0

HOTKEYS STOP - Stops hotkeys tracking. ⭐ New in 8.6

**Syntax:** `HOTKEYS STOP`

**Description:** Stops hotkeys tracking.

**Complexity:** O(1)

**Since:** 8.6.0

INFO - Returns information and statistics about the server.

**Syntax:** `INFO [section [section ...]]`

**Description:** Returns information and statistics about the server.

**Complexity:** O(1)

**Since:** 1.0.0

LASTSAVE - Returns the Unix timestamp of the last successful save to disk.

**Syntax:** `LASTSAVE`

**Description:** Returns the Unix timestamp of the last successful save to disk.

**Complexity:** O(1)

**Since:** 1.0.0

LATENCY DOCTOR - Returns a human-readable latency analysis report.

**Syntax:** `LATENCY DOCTOR`

**Description:** Returns a human-readable latency analysis report.

**Complexity:** O(1)

**Since:** 2.8.13

LATENCY GRAPH - Returns a latency graph for an event.

**Syntax:** `LATENCY GRAPH event`

**Description:** Returns a latency graph for an event.

**Complexity:** O(1)

**Since:** 2.8.13

LATENCY HISTOGRAM - Returns the cumulative distribution of latencies of a subset or all commands.

**Syntax:** `LATENCY HISTOGRAM [command [command ...]]`

**Description:** Returns the cumulative distribution of latencies of a subset or all commands.

**Complexity:** O(N) where N is the number of commands with latency information being retrieved.

**Since:** 7.0.0

LATENCY HISTORY - Returns timestamp-latency samples for an event.

**Syntax:** `LATENCY HISTORY event`

**Description:** Returns timestamp-latency samples for an event.

**Complexity:** O(1)

**Since:** 2.8.13

LATENCY LATEST - Returns the latest latency samples for all events.

**Syntax:** `LATENCY LATEST`

**Description:** Returns the latest latency samples for all events.

**Complexity:** O(1)

**Since:** 2.8.13

LATENCY RESET - Resets the latency data for one or more events.

**Syntax:** `LATENCY RESET [event [event ...]]`

**Description:** Resets the latency data for one or more events.

**Complexity:** O(1)

**Since:** 2.8.13

LOLWUT - Displays computer art and the Redis version

**Syntax:** `LOLWUT [VERSION version]`

**Description:** Displays computer art and the Redis version

**Complexity:**

**Since:** 5.0.0

MEMORY DOCTOR - Outputs a memory problems report.

**Syntax:** `MEMORY DOCTOR`

**Description:** Outputs a memory problems report.

**Complexity:** O(1)

**Since:** 4.0.0

MEMORY MALLOC-STATS - Returns the allocator statistics.

**Syntax:** `MEMORY MALLOC-STATS`

**Description:** Returns the allocator statistics.

**Complexity:** Depends on how much memory is allocated, could be slow

**Since:** 4.0.0

MEMORY PURGE - Asks the allocator to release memory.

**Syntax:** `MEMORY PURGE`

**Description:** Asks the allocator to release memory.

**Complexity:** Depends on how much memory is allocated, could be slow

**Since:** 4.0.0

MEMORY STATS - Returns details about memory usage.

**Syntax:** `MEMORY STATS`

**Description:** Returns details about memory usage.

**Complexity:** O(1)

**Since:** 4.0.0

MEMORY USAGE - Estimates the memory usage of a key.

**Syntax:** `MEMORY USAGE key [SAMPLES count]`

**Description:** Estimates the memory usage of a key.

**Complexity:** O(N) where N is the number of samples.

**Since:** 4.0.0

MODULE LIST - Returns all loaded modules.

**Syntax:** `MODULE LIST`

**Description:** Returns all loaded modules.

**Complexity:** O(N) where N is the number of loaded modules.

**Since:** 4.0.0

MODULE LOAD - Loads a module.

**Syntax:** `MODULE LOAD path [arg [arg ...]]`

**Description:** Loads a module.

**Complexity:** O(1)

**Since:** 4.0.0

MODULE LOADEX - Loads a module using extended parameters.

**Syntax:** `MODULE LOADEX path [CONFIG name value [CONFIG name value ...]]
  [ARGS args [args ...]]`

**Description:** Loads a module using extended parameters.

**Complexity:** O(1)

**Since:** 7.0.0

MODULE UNLOAD - Unloads a module.

**Syntax:** `MODULE UNLOAD name`

**Description:** Unloads a module.

**Complexity:** O(1)

**Since:** 4.0.0

MONITOR - Listens for all requests received by the server in real-time.

**Syntax:** `MONITOR`

**Description:** Listens for all requests received by the server in real-time.

**Complexity:**

**Since:** 1.0.0

PSYNC - An internal command used in replication.

**Syntax:** `PSYNC replicationid offset`

**Description:** An internal command used in replication.

**Complexity:**

**Since:** 2.8.0

REPLCONF - An internal command for configuring the replication stream.

**Syntax:** `REPLCONF`

**Description:** An internal command for configuring the replication stream.

**Complexity:** O(1)

**Since:** 3.0.0

REPLICAOF - Configures a server as replica of another, or promotes it to a master.

**Syntax:** `REPLICAOF <host port | NO ONE>`

**Description:** Configures a server as replica of another, or promotes it to a master.

**Complexity:** O(1)

**Since:** 5.0.0

RESTORE-ASKING - An internal command for migrating keys in a cluster.

**Syntax:** `RESTORE-ASKING key ttl serialized-value [REPLACE] [ABSTTL]
  [IDLETIME seconds] [FREQ frequency]`

**Description:** An internal command for migrating keys in a cluster.

**Complexity:** O(1) to create the new key and additional O(N*M) to reconstruct the serialized value, where N is the number of Redis objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1*M) where M is small, so simply O(1). However for sorted set values the complexity is O(N*M*log(N)) because inserting values into sorted sets is O(log(N)).

**Since:** 3.0.0

ROLE - Returns the replication role.

**Syntax:** `ROLE`

**Description:** Returns the replication role.

**Complexity:** O(1)

**Since:** 2.8.12

SAVE - Synchronously saves the database(s) to disk.

**Syntax:** `SAVE`

**Description:** Synchronously saves the database(s) to disk.

**Complexity:** O(N) where N is the total number of keys in all databases

**Since:** 1.0.0

SHUTDOWN - Synchronously saves the database(s) to disk and shuts down the Redis server.

**Syntax:** `SHUTDOWN [NOSAVE | SAVE] [NOW] [FORCE] [ABORT]`

**Description:** Synchronously saves the database(s) to disk and shuts down the Redis server.

**Complexity:** O(N) when saving, where N is the total number of keys in all databases when saving data, otherwise O(1)

**Since:** 1.0.0

SLAVEOF - Sets a Redis server as a replica of another, or promotes it to being a master.

**Syntax:** `SLAVEOF <host port | NO ONE>`

**Description:** Sets a Redis server as a replica of another, or promotes it to being a master.

**Complexity:** O(1)

**Since:** 1.0.0

SLOWLOG GET - Returns the slow log's entries.

**Syntax:** `SLOWLOG GET [count]`

**Description:** Returns the slow log's entries.

**Complexity:** O(N) where N is the number of entries returned

**Since:** 2.2.12

SLOWLOG LEN - Returns the number of entries in the slow log.

**Syntax:** `SLOWLOG LEN`

**Description:** Returns the number of entries in the slow log.

**Complexity:** O(1)

**Since:** 2.2.12

SLOWLOG RESET - Clears all entries from the slow log.

**Syntax:** `SLOWLOG RESET`

**Description:** Clears all entries from the slow log.

**Complexity:** O(N) where N is the number of entries in the slowlog

**Since:** 2.2.12

SWAPDB - Swaps two Redis databases.

**Syntax:** `SWAPDB index1 index2`

**Description:** Swaps two Redis databases.

**Complexity:** O(N) where N is the count of clients watching or blocking on keys from both databases.

**Since:** 4.0.0

SYNC - An internal command used in replication.

**Syntax:** `SYNC`

**Description:** An internal command used in replication.

**Complexity:**

**Since:** 1.0.0

TIME - Returns the server time.

**Syntax:** `TIME`

**Description:** Returns the server time.

**Complexity:** O(1)

**Since:** 2.6.0

title: Cluster commands

text:
Cluster commands manage Redis Cluster operations.

ASKING - Signals that a cluster client is following an -ASK redirect.

**Syntax:** `ASKING`

**Description:** Signals that a cluster client is following an -ASK redirect.

**Complexity:** O(1)

**Since:** 3.0.0

CLUSTER ADDSLOTS - Assigns new hash slots to a node.

**Syntax:** `CLUSTER ADDSLOTS slot [slot ...]`

**Description:** Assigns new hash slots to a node.

**Complexity:** O(N) where N is the total number of hash slot arguments

**Since:** 3.0.0

CLUSTER ADDSLOTSRANGE - Assigns new hash slot ranges to a node.

**Syntax:** `CLUSTER ADDSLOTSRANGE start-slot end-slot [start-slot end-slot ...]`

**Description:** Assigns new hash slot ranges to a node.

**Complexity:** O(N) where N is the total number of the slots between the start slot and end slot arguments.

**Since:** 7.0.0

CLUSTER BUMPEPOCH - Advances the cluster config epoch.

**Syntax:** `CLUSTER BUMPEPOCH`

**Description:** Advances the cluster config epoch.

**Complexity:** O(1)

**Since:** 3.0.0

CLUSTER COUNT-FAILURE-REPORTS - Returns the number of active failure reports active for a node.

**Syntax:** `CLUSTER COUNT-FAILURE-REPORTS node-id`

**Description:** Returns the number of active failure reports active for a node.

**Complexity:** O(N) where N is the number of failure reports

**Since:** 3.0.0

CLUSTER COUNTKEYSINSLOT - Returns the number of keys in a hash slot.

**Syntax:** `CLUSTER COUNTKEYSINSLOT slot`

**Description:** Returns the number of keys in a hash slot.

**Complexity:** O(1)

**Since:** 3.0.0

CLUSTER DELSLOTS - Sets hash slots as unbound for a node.

**Syntax:** `CLUSTER DELSLOTS slot [slot ...]`

**Description:** Sets hash slots as unbound for a node.

**Complexity:** O(N) where N is the total number of hash slot arguments

**Since:** 3.0.0

CLUSTER DELSLOTSRANGE - Sets hash slot ranges as unbound for a node.

**Syntax:** `CLUSTER DELSLOTSRANGE start-slot end-slot [start-slot end-slot ...]`

**Description:** Sets hash slot ranges as unbound for a node.

**Complexity:** O(N) where N is the total number of the slots between the start slot and end slot arguments.

**Since:** 7.0.0

CLUSTER FAILOVER - Forces a replica to perform a manual failover of its master.

**Syntax:** `CLUSTER FAILOVER [FORCE | TAKEOVER]`

**Description:** Forces a replica to perform a manual failover of its master.

**Complexity:** O(1)

**Since:** 3.0.0

CLUSTER FLUSHSLOTS - Deletes all slots information from a node.

**Syntax:** `CLUSTER FLUSHSLOTS`

**Description:** Deletes all slots information from a node.

**Complexity:** O(1)

**Since:** 3.0.0

CLUSTER FORGET - Removes a node from the nodes table.

**Syntax:** `CLUSTER FORGET node-id`

**Description:** Removes a node from the nodes table.

**Complexity:** O(1)

**Since:** 3.0.0

CLUSTER GETKEYSINSLOT - Returns the key names in a hash slot.

**Syntax:** `CLUSTER GETKEYSINSLOT slot count`

**Description:** Returns the key names in a hash slot.

**Complexity:** O(N) where N is the number of requested keys

**Since:** 3.0.0

CLUSTER INFO - Returns information about the state of a node.

**Syntax:** `CLUSTER INFO`

**Description:** Returns information about the state of a node.

**Complexity:** O(1)

**Since:** 3.0.0

CLUSTER KEYSLOT - Returns the hash slot for a key.

**Syntax:** `CLUSTER KEYSLOT key`

**Description:** Returns the hash slot for a key.

**Complexity:** O(N) where N is the number of bytes in the key

**Since:** 3.0.0

CLUSTER LINKS - Returns a list of all TCP links to and from peer nodes.

**Syntax:** `CLUSTER LINKS`

**Description:** Returns a list of all TCP links to and from peer nodes.

**Complexity:** O(N) where N is the total number of Cluster nodes

**Since:** 7.0.0

CLUSTER MEET - Forces a node to handshake with another node.

**Syntax:** `CLUSTER MEET ip port [cluster-bus-port]`

**Description:** Forces a node to handshake with another node.

**Complexity:** O(1)

**Since:** 3.0.0

CLUSTER MIGRATION - Start, monitor, and cancel atomic slot migration tasks.

**Syntax:** `CLUSTER MIGRATION <IMPORT start-slot end-slot
  [start-slot end-slot ...] | CANCEL <ID task-id | ALL> |
  STATUS <[ID task-id] | [ALL]>>`

**Description:** Start, monitor, and cancel atomic slot migration tasks.

**Complexity:** O(N) where N is the total number of the slots between the start slot and end slot arguments.

**Since:** 8.4.0

CLUSTER MYID - Returns the ID of a node.

**Syntax:** `CLUSTER MYID`

**Description:** Returns the ID of a node.

**Complexity:** O(1)

**Since:** 3.0.0

CLUSTER MYSHARDID - Returns the shard ID of a node.

**Syntax:** `CLUSTER MYSHARDID`

**Description:** Returns the shard ID of a node.

**Complexity:** O(1)

**Since:** 7.2.0

CLUSTER NODES - Returns the cluster configuration for a node.

**Syntax:** `CLUSTER NODES`

**Description:** Returns the cluster configuration for a node.

**Complexity:** O(N) where N is the total number of Cluster nodes

**Since:** 3.0.0

CLUSTER REPLICAS - Lists the replica nodes of a master node.

**Syntax:** `CLUSTER REPLICAS node-id`

**Description:** Lists the replica nodes of a master node.

**Complexity:** O(N) where N is the number of replicas.

**Since:** 5.0.0

CLUSTER REPLICATE - Configure a node as replica of a master node.

**Syntax:** `CLUSTER REPLICATE node-id`

**Description:** Configure a node as replica of a master node.

**Complexity:** O(1)

**Since:** 3.0.0

CLUSTER RESET - Resets a node.

**Syntax:** `CLUSTER RESET [HARD | SOFT]`

**Description:** Resets a node.

**Complexity:** O(N) where N is the number of known nodes. The command may execute a FLUSHALL as a side effect.

**Since:** 3.0.0

CLUSTER SAVECONFIG - Forces a node to save the cluster configuration to disk.

**Syntax:** `CLUSTER SAVECONFIG`

**Description:** Forces a node to save the cluster configuration to disk.

**Complexity:** O(1)

**Since:** 3.0.0

CLUSTER SET-CONFIG-EPOCH - Sets the configuration epoch for a new node.

**Syntax:** `CLUSTER SET-CONFIG-EPOCH config-epoch`

**Description:** Sets the configuration epoch for a new node.

**Complexity:** O(1)

**Since:** 3.0.0

CLUSTER SETSLOT - Binds a hash slot to a node.

**Syntax:** `CLUSTER SETSLOT slot <IMPORTING node-id | MIGRATING node-id |
  NODE node-id | STABLE>`

**Description:** Binds a hash slot to a node.

**Complexity:** O(1)

**Since:** 3.0.0

CLUSTER SHARDS - Returns the mapping of cluster slots to shards.

**Syntax:** `CLUSTER SHARDS`

**Description:** Returns the mapping of cluster slots to shards.

**Complexity:** O(N) where N is the total number of cluster nodes

**Since:** 7.0.0

CLUSTER SLAVES - Lists the replica nodes of a master node.

**Syntax:** `CLUSTER SLAVES node-id`

**Description:** Lists the replica nodes of a master node.

**Complexity:** O(N) where N is the number of replicas.

**Since:** 3.0.0

CLUSTER SLOT-STATS - Return an array of slot usage statistics for slots assigned to the current node.

**Syntax:** `CLUSTER SLOT-STATS <SLOTSRANGE start-slot end-slot | ORDERBY metric
  [LIMIT limit] [ASC | DESC]>`

**Description:** Return an array of slot usage statistics for slots assigned to the current node.

**Complexity:** O(N) where N is the total number of slots based on arguments. O(N*log(N)) with ORDERBY subcommand.

**Since:** 8.2.0

CLUSTER SLOTS - Returns the mapping of cluster slots to nodes.

**Syntax:** `CLUSTER SLOTS`

**Description:** Returns the mapping of cluster slots to nodes.

**Complexity:** O(N) where N is the total number of Cluster nodes

**Since:** 3.0.0

READONLY - Enables read-only queries for a connection to a Redis Cluster replica node.

**Syntax:** `READONLY`

**Description:** Enables read-only queries for a connection to a Redis Cluster replica node.

**Complexity:** O(1)

**Since:** 3.0.0

READWRITE - Enables read-write queries for a connection to a Reids Cluster replica node.

**Syntax:** `READWRITE`

**Description:** Enables read-write queries for a connection to a Reids Cluster replica node.

**Complexity:** O(1)

**Since:** 3.0.0

title: Generic commands

text:
Generic commands work across all data types.

COPY - Copies the value of a key to a new key.

**Syntax:** `COPY source destination [DB destination-db] [REPLACE]`

**Description:** Copies the value of a key to a new key.

**Complexity:** O(N) worst case for collections, where N is the number of nested items. O(1) for string values.

**Since:** 6.2.0

DEL - Deletes one or more keys.

**Syntax:** `DEL key [key ...]`

**Description:** Deletes one or more keys.

**Complexity:** O(N) where N is the number of keys that will be removed. When a key to remove holds a value other than a string, the individual complexity for this key is O(M) where M is the number of elements in the list, set, sorted set or hash. Removing a single key that holds a string value is O(1).

**Since:** 1.0.0

DUMP - Returns a serialized representation of the value stored at a key.

**Syntax:** `DUMP key`

**Description:** Returns a serialized representation of the value stored at a key.

**Complexity:** O(1) to access the key and additional O(N*M) to serialize it, where N is the number of Redis objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1*M) where M is small, so simply O(1).

**Since:** 2.6.0

EXISTS - Determines whether one or more keys exist.

**Syntax:** `EXISTS key [key ...]`

**Description:** Determines whether one or more keys exist.

**Complexity:** O(N) where N is the number of keys to check.

**Since:** 1.0.0

EXPIRE - Sets the expiration time of a key in seconds.

**Syntax:** `EXPIRE key seconds [NX | XX | GT | LT]`

**Description:** Sets the expiration time of a key in seconds.

**Complexity:** O(1)

**Since:** 1.0.0

EXPIREAT - Sets the expiration time of a key to a Unix timestamp.

**Syntax:** `EXPIREAT key unix-time-seconds [NX | XX | GT | LT]`

**Description:** Sets the expiration time of a key to a Unix timestamp.

**Complexity:** O(1)

**Since:** 1.2.0

EXPIRETIME - Returns the expiration time of a key as a Unix timestamp.

**Syntax:** `EXPIRETIME key`

**Description:** Returns the expiration time of a key as a Unix timestamp.

**Complexity:** O(1)

**Since:** 7.0.0

KEYS - Returns all key names that match a pattern.

**Syntax:** `KEYS pattern`

**Description:** Returns all key names that match a pattern.

**Complexity:** O(N) with N being the number of keys in the database, under the assumption that the key names in the database and the given pattern have limited length.

**Since:** 1.0.0

MIGRATE - Atomically transfers a key from one Redis instance to another.

**Syntax:** `MIGRATE host port <key | ""> destination-db timeout [COPY] [REPLACE]
  [AUTH password | AUTH2 username password] [KEYS key [key ...]]`

**Description:** Atomically transfers a key from one Redis instance to another.

**Complexity:** This command actually executes a DUMP+DEL in the source instance, and a RESTORE in the target instance. See the pages of these commands for time complexity. Also an O(N) data transfer between the two instances is performed.

**Since:** 2.6.0

MOVE - Moves a key to another database.

**Syntax:** `MOVE key db`

**Description:** Moves a key to another database.

**Complexity:** O(1)

**Since:** 1.0.0

OBJECT ENCODING - Returns the internal encoding of a Redis object.

**Syntax:** `OBJECT ENCODING key`

**Description:** Returns the internal encoding of a Redis object.

**Complexity:** O(1)

**Since:** 2.2.3

OBJECT FREQ - Returns the logarithmic access frequency counter of a Redis object.

**Syntax:** `OBJECT FREQ key`

**Description:** Returns the logarithmic access frequency counter of a Redis object.

**Complexity:** O(1)

**Since:** 4.0.0

OBJECT IDLETIME - Returns the time since the last access to a Redis object.

**Syntax:** `OBJECT IDLETIME key`

**Description:** Returns the time since the last access to a Redis object.

**Complexity:** O(1)

**Since:** 2.2.3

OBJECT REFCOUNT - Returns the reference count of a value of a key.

**Syntax:** `OBJECT REFCOUNT key`

**Description:** Returns the reference count of a value of a key.

**Complexity:** O(1)

**Since:** 2.2.3

PERSIST - Removes the expiration time of a key.

**Syntax:** `PERSIST key`

**Description:** Removes the expiration time of a key.

**Complexity:** O(1)

**Since:** 2.2.0

PEXPIRE - Sets the expiration time of a key in milliseconds.

**Syntax:** `PEXPIRE key milliseconds [NX | XX | GT | LT]`

**Description:** Sets the expiration time of a key in milliseconds.

**Complexity:** O(1)

**Since:** 2.6.0

PEXPIREAT - Sets the expiration time of a key to a Unix milliseconds timestamp.

**Syntax:** `PEXPIREAT key unix-time-milliseconds [NX | XX | GT | LT]`

**Description:** Sets the expiration time of a key to a Unix milliseconds timestamp.

**Complexity:** O(1)

**Since:** 2.6.0

PEXPIRETIME - Returns the expiration time of a key as a Unix milliseconds timestamp.

**Syntax:** `PEXPIRETIME key`

**Description:** Returns the expiration time of a key as a Unix milliseconds timestamp.

**Complexity:** O(1)

**Since:** 7.0.0

PTTL - Returns the expiration time in milliseconds of a key.

**Syntax:** `PTTL key`

**Description:** Returns the expiration time in milliseconds of a key.

**Complexity:** O(1)

**Since:** 2.6.0

RANDOMKEY - Returns a random key name from the database.

**Syntax:** `RANDOMKEY`

**Description:** Returns a random key name from the database.

**Complexity:** O(1)

**Since:** 1.0.0

RENAME - Renames a key and overwrites the destination.

**Syntax:** `RENAME key newkey`

**Description:** Renames a key and overwrites the destination.

**Complexity:** O(1)

**Since:** 1.0.0

RENAMENX - Renames a key only when the target key name doesn't exist.

**Syntax:** `RENAMENX key newkey`

**Description:** Renames a key only when the target key name doesn't exist.

**Complexity:** O(1)

**Since:** 1.0.0

RESTORE - Creates a key from the serialized representation of a value.

**Syntax:** `RESTORE key ttl serialized-value [REPLACE] [ABSTTL]
  [IDLETIME seconds] [FREQ frequency]`

**Description:** Creates a key from the serialized representation of a value.

**Complexity:** O(1) to create the new key and additional O(N*M) to reconstruct the serialized value, where N is the number of Redis objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1*M) where M is small, so simply O(1). However for sorted set values the complexity is O(N*M*log(N)) because inserting values into sorted sets is O(log(N)).

**Since:** 2.6.0

Redis 6.2 Commands Reference - Complete list of all Redis commands available in version 6.2, organized by functional group

**Syntax:** ``

**Description:** Complete list of all Redis commands available in version 6.2, organized by functional group

**Complexity:**

**Since:**

Redis 7.2 Commands Reference - Complete list of all Redis commands available in version 7.2, organized by functional group

**Syntax:** ``

**Description:** Complete list of all Redis commands available in version 7.2, organized by functional group

**Complexity:**

**Since:**

Redis 7.4 Commands Reference - Complete list of all Redis commands available in version 7.4, organized by functional group

**Syntax:** ``

**Description:** Complete list of all Redis commands available in version 7.4, organized by functional group

**Complexity:**

**Since:**

Redis 8.0 Commands Reference - Complete list of all Redis commands available in version 8.0, organized by functional group

**Syntax:** ``

**Description:** Complete list of all Redis commands available in version 8.0, organized by functional group

**Complexity:**

**Since:**

Redis 8.2 Commands Reference - Complete list of all Redis commands available in version 8.2, organized by functional group

**Syntax:** ``

**Description:** Complete list of all Redis commands available in version 8.2, organized by functional group

**Complexity:**

**Since:**

Redis 8.4 Commands Reference - Complete list of all Redis commands available in version 8.4, organized by functional group

**Syntax:** ``

**Description:** Complete list of all Redis commands available in version 8.4, organized by functional group

**Complexity:**

**Since:**

Redis 8.6 Commands Reference - Complete list of all Redis commands available in version 8.6, organized by functional group

**Syntax:** ``

**Description:** Complete list of all Redis commands available in version 8.6, organized by functional group

**Complexity:**

**Since:**

SCAN - Iterates over the key names in the database.

**Syntax:** `SCAN cursor [MATCH pattern] [COUNT count] [TYPE type]`

**Description:** Iterates over the key names in the database.

**Complexity:** O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection.

**Since:** 2.8.0

SORT - Sorts the elements in a list, a set, or a sorted set, optionally storing the result.

**Syntax:** `SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern
  ...]] [ASC | DESC] [ALPHA] [STORE destination]`

**Description:** Sorts the elements in a list, a set, or a sorted set, optionally storing the result.

**Complexity:** O(N+M*log(M)) where N is the number of elements in the list or set to sort, and M the number of returned elements. When the elements are not sorted, complexity is O(N).

**Since:** 1.0.0

SORT_RO - Returns the sorted elements of a list, a set, or a sorted set.

**Syntax:** `SORT RO key [BY pattern] [LIMIT offset count] [GET pattern [GET
  pattern ...]] [ASC | DESC] [ALPHA]`

**Description:** Returns the sorted elements of a list, a set, or a sorted set.

**Complexity:** O(N+M*log(M)) where N is the number of elements in the list or set to sort, and M the number of returned elements. When the elements are not sorted, complexity is O(N).

**Since:** 7.0.0

TOUCH - Returns the number of existing keys out of those specified after updating the time they were last accessed.

**Syntax:** `TOUCH key [key ...]`

**Description:** Returns the number of existing keys out of those specified after updating the time they were last accessed.

**Complexity:** O(N) where N is the number of keys that will be touched.

**Since:** 3.2.1

TTL - Returns the expiration time in seconds of a key.

**Syntax:** `TTL key`

**Description:** Returns the expiration time in seconds of a key.

**Complexity:** O(1)

**Since:** 1.0.0

TYPE - Determines the type of value stored at a key.

**Syntax:** `TYPE key`

**Description:** Determines the type of value stored at a key.

**Complexity:** O(1)

**Since:** 1.0.0

UNLINK - Asynchronously deletes one or more keys.

**Syntax:** `UNLINK key [key ...]`

**Description:** Asynchronously deletes one or more keys.

**Complexity:** O(1) for each key removed regardless of its size. Then the command does O(N) work in a different thread in order to reclaim memory, where N is the number of allocations the deleted objects where composed of.

**Since:** 4.0.0

WAIT - Blocks until the asynchronous replication of all preceding write commands sent by the connection is completed.

**Syntax:** `WAIT numreplicas timeout`

**Description:** Blocks until the asynchronous replication of all preceding write commands sent by the connection is completed.

**Complexity:** O(1)

**Since:** 3.0.0

WAITAOF - Blocks until all of the preceding write commands sent by the connection are written to the append-only file of the master and/or replicas.

**Syntax:** `WAITAOF numlocal numreplicas timeout`

**Description:** Blocks until all of the preceding write commands sent by the connection are written to the append-only file of the master and/or replicas.

**Complexity:** O(1)

**Since:** 7.2.0