title: Redis 8.0 Commands Reference

summary: Complete list of all Redis commands available in version 8.0, organized by functional group

page_type: content

title: Overview

role: overview

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

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

Command page links take you to the *current implementation* of each command.

title: Quick Navigation

role: content

text:
- [String commands](#string-commands)
- [Hash commands](#hash-commands)
- [List commands](#list-commands)
- [Set commands](#set-commands)
- [Sorted set commands](#sorted-set-commands)
- [Stream commands](#stream-commands)
- [Bitmap commands](#bitmap-commands)
- [HyperLogLog commands](#hyperloglog-commands)
- [Geospatial commands](#geospatial-commands)
- [JSON commands](#json-commands)
- [Search commands](#search-commands)
- [Time series commands](#time-series-commands)
- [Vector set commands](#vector-set-commands)
- [Pub/Sub commands](#pubsub-commands)
- [Transaction commands](#transaction-commands)
- [Scripting commands](#scripting-commands)
- [Connection commands](#connection-commands)
- [Server commands](#server-commands)
- [Cluster commands](#cluster-commands)
- [Generic commands](#generic-commands)

---

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

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

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. ⭐ New in 8.0

**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. ⭐ New in 8.0

**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. ⭐ New in 8.0

**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

text:
List commands operate on lists of strings, ordered by insertion order.

BLMOVE - Pops an element from a list, pushes it to another list and returns it. Blocks until an element is available otherwise. Deletes the list if the last element was moved.

**Syntax:** `BLMOVE source destination <LEFT | RIGHT> <LEFT | RIGHT> timeout`

**Description:** Pops an element from a list, pushes it to another list and returns it. Blocks until an element is available otherwise. Deletes the list if the last element was moved.

**Complexity:** O(1)

**Since:** 6.2.0

BLMPOP - Pops the first element from one of multiple lists. Blocks until an element is available otherwise. Deletes the list if the last element was popped.

**Syntax:** `BLMPOP timeout numkeys key [key ...] <LEFT | RIGHT> [COUNT count]`

**Description:** Pops the first element from one of multiple lists. Blocks until an element is available otherwise. Deletes the list if the last element was popped.

**Complexity:** O(N+M) where N is the number of provided keys and M is the number of elements returned.

**Since:** 7.0.0

BLPOP - Removes and returns the first element in a list. Blocks until an element is available otherwise. Deletes the list if the last element was popped.

**Syntax:** `BLPOP key [key ...] timeout`

**Description:** Removes and returns the first element in a list. Blocks until an element is available otherwise. Deletes the list if the last element was popped.

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

**Since:** 2.0.0

BRPOP - Removes and returns the last element in a list. Blocks until an element is available otherwise. Deletes the list if the last element was popped.

**Syntax:** `BRPOP key [key ...] timeout`

**Description:** Removes and returns the last element in a list. Blocks until an element is available otherwise. Deletes the list if the last element was popped.

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

**Since:** 2.0.0

BRPOPLPUSH - Pops an element from a list, pushes it to another list and returns it. Block until an element is available otherwise. Deletes the list if the last element was popped.

**Syntax:** `BRPOPLPUSH source destination timeout`

**Description:** Pops an element from a list, pushes it to another list and returns it. Block until an element is available otherwise. Deletes the list if the last element was popped.

**Complexity:** O(1)

**Since:** 2.2.0

LINDEX - Returns an element from a list by its index.

**Syntax:** `LINDEX key index`

**Description:** Returns an element from a list by its index.

**Complexity:** O(N) where N is the number of elements to traverse to get to the element at index. This makes asking for the first or the last element of the list O(1).

**Since:** 1.0.0

LINSERT - Inserts an element before or after another element in a list.

**Syntax:** `LINSERT key <BEFORE | AFTER> pivot element`

**Description:** Inserts an element before or after another element in a list.

**Complexity:** O(N) where N is the number of elements to traverse before seeing the value pivot. This means that inserting somewhere on the left end on the list (head) can be considered O(1) and inserting somewhere on the right end (tail) is O(N).

**Since:** 2.2.0

LLEN - Returns the length of a list.

**Syntax:** `LLEN key`

**Description:** Returns the length of a list.

**Complexity:** O(1)

**Since:** 1.0.0

LMOVE - Returns an element after popping it from one list and pushing it to another. Deletes the list if the last element was moved.

**Syntax:** `LMOVE source destination <LEFT | RIGHT> <LEFT | RIGHT>`

**Description:** Returns an element after popping it from one list and pushing it to another. Deletes the list if the last element was moved.

**Complexity:** O(1)

**Since:** 6.2.0

LMPOP - Returns multiple elements from a list after removing them. Deletes the list if the last element was popped.

**Syntax:** `LMPOP numkeys key [key ...] <LEFT | RIGHT> [COUNT count]`

**Description:** Returns multiple elements from a list after removing them. Deletes the list if the last element was popped.

**Complexity:** O(N+M) where N is the number of provided keys and M is the number of elements returned.

**Since:** 7.0.0

LPOP - Returns the first elements in a list after removing it. Deletes the list if the last element was popped.

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

**Description:** Returns the first elements in a list after removing it. Deletes the list if the last element was popped.

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

**Since:** 1.0.0

LPOS - Returns the index of matching elements in a list.

**Syntax:** `LPOS key element [RANK rank] [COUNT num-matches] [MAXLEN len]`

**Description:** Returns the index of matching elements in a list.

**Complexity:** O(N) where N is the number of elements in the list, for the average case. When searching for elements near the head or the tail of the list, or when the MAXLEN option is provided, the command may run in constant time.

**Since:** 6.0.6

LPUSH - Prepends one or more elements to a list. Creates the key if it doesn't exist.

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

**Description:** Prepends one or more elements to a list. Creates the key if it doesn't exist.

**Complexity:** O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.

**Since:** 1.0.0

LPUSHX - Prepends one or more elements to a list only when the list exists.

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

**Description:** Prepends one or more elements to a list only when the list exists.

**Complexity:** O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.

**Since:** 2.2.0

LRANGE - Returns a range of elements from a list.

**Syntax:** `LRANGE key start stop`

**Description:** Returns a range of elements from a list.

**Complexity:** O(S+N) where S is the distance of start offset from HEAD for small lists, from nearest end (HEAD or TAIL) for large lists; and N is the number of elements in the specified range.

**Since:** 1.0.0

LREM - Removes elements from a list. Deletes the list if the last element was removed.

**Syntax:** `LREM key count element`

**Description:** Removes elements from a list. Deletes the list if the last element was removed.

**Complexity:** O(N+M) where N is the length of the list and M is the number of elements removed.

**Since:** 1.0.0

LSET - Sets the value of an element in a list by its index.

**Syntax:** `LSET key index element`

**Description:** Sets the value of an element in a list by its index.

**Complexity:** O(N) where N is the length of the list. Setting either the first or the last element of the list is O(1).

**Since:** 1.0.0

LTRIM - Removes elements from both ends a list. Deletes the list if all elements were trimmed.

**Syntax:** `LTRIM key start stop`

**Description:** Removes elements from both ends a list. Deletes the list if all elements were trimmed.

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

**Since:** 1.0.0

RPOP - Returns and removes the last elements of a list. Deletes the list if the last element was popped.

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

**Description:** Returns and removes the last elements of a list. Deletes the list if the last element was popped.

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

**Since:** 1.0.0

RPOPLPUSH - Returns the last element of a list after removing and pushing it to another list. Deletes the list if the last element was popped.

**Syntax:** `RPOPLPUSH source destination`

**Description:** Returns the last element of a list after removing and pushing it to another list. Deletes the list if the last element was popped.

**Complexity:** O(1)

**Since:** 1.2.0

RPUSH - Appends one or more elements to a list. Creates the key if it doesn't exist.

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

**Description:** Appends one or more elements to a list. Creates the key if it doesn't exist.

**Complexity:** O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.

**Since:** 1.0.0

RPUSHX - Appends an element to a list only when the list exists.

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

**Description:** Appends an element to a list only when the list exists.

**Complexity:** O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.

**Since:** 2.2.0

title: Set commands

text:
Set commands operate on unordered collections of unique strings.

SADD - Adds one or more members to a set. Creates the key if it doesn't exist.

**Syntax:** `SADD key member [member ...]`

**Description:** Adds one or more members to a set. Creates the key if it doesn't exist.

**Complexity:** O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.

**Since:** 1.0.0

SCARD - Returns the number of members in a set.

**Syntax:** `SCARD key`

**Description:** Returns the number of members in a set.

**Complexity:** O(1)

**Since:** 1.0.0

SDIFF - Returns the difference of multiple sets.

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

**Description:** Returns the difference of multiple sets.

**Complexity:** O(N) where N is the total number of elements in all given sets.

**Since:** 1.0.0

SDIFFSTORE - Stores the difference of multiple sets in a key.

**Syntax:** `SDIFFSTORE destination key [key ...]`

**Description:** Stores the difference of multiple sets in a key.

**Complexity:** O(N) where N is the total number of elements in all given sets.

**Since:** 1.0.0

SINTER - Returns the intersect of multiple sets.

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

**Description:** Returns the intersect of multiple sets.

**Complexity:** O(N*M) worst case where N is the cardinality of the smallest set and M is the number of sets.

**Since:** 1.0.0

SINTERCARD - Returns the number of members of the intersect of multiple sets.

**Syntax:** `SINTERCARD numkeys key [key ...] [LIMIT limit]`

**Description:** Returns the number of members of the intersect of multiple sets.

**Complexity:** O(N*M) worst case where N is the cardinality of the smallest set and M is the number of sets.

**Since:** 7.0.0

SINTERSTORE - Stores the intersect of multiple sets in a key.

**Syntax:** `SINTERSTORE destination key [key ...]`

**Description:** Stores the intersect of multiple sets in a key.

**Complexity:** O(N*M) worst case where N is the cardinality of the smallest set and M is the number of sets.

**Since:** 1.0.0

SISMEMBER - Determines whether a member belongs to a set.

**Syntax:** `SISMEMBER key member`

**Description:** Determines whether a member belongs to a set.

**Complexity:** O(1)

**Since:** 1.0.0

SMEMBERS - Returns all members of a set.

**Syntax:** `SMEMBERS key`

**Description:** Returns all members of a set.

**Complexity:** O(N) where N is the set cardinality.

**Since:** 1.0.0

SMISMEMBER - Determines whether multiple members belong to a set.

**Syntax:** `SMISMEMBER key member [member ...]`

**Description:** Determines whether multiple members belong to a set.

**Complexity:** O(N) where N is the number of elements being checked for membership

**Since:** 6.2.0

SMOVE - Moves a member from one set to another.

**Syntax:** `SMOVE source destination member`

**Description:** Moves a member from one set to another.

**Complexity:** O(1)

**Since:** 1.0.0

SPOP - Returns one or more random members from a set after removing them. Deletes the set if the last member was popped.

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

**Description:** Returns one or more random members from a set after removing them. Deletes the set if the last member was popped.

**Complexity:** Without the count argument O(1), otherwise O(N) where N is the value of the passed count.

**Since:** 1.0.0

SRANDMEMBER - Get one or multiple random members from a set

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

**Description:** Get one or multiple random members from a set

**Complexity:** Without the count argument O(1), otherwise O(N) where N is the absolute value of the passed count.

**Since:** 1.0.0

SREM - Removes one or more members from a set. Deletes the set if the last member was removed.

**Syntax:** `SREM key member [member ...]`

**Description:** Removes one or more members from a set. Deletes the set if the last member was removed.

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

**Since:** 1.0.0

SSCAN - Iterates over members of a set.

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

**Description:** Iterates over members of a set.

**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

SUNION - Returns the union of multiple sets.

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

**Description:** Returns the union of multiple sets.

**Complexity:** O(N) where N is the total number of elements in all given sets.

**Since:** 1.0.0

SUNIONSTORE - Stores the union of multiple sets in a key.

**Syntax:** `SUNIONSTORE destination key [key ...]`

**Description:** Stores the union of multiple sets in a key.

**Complexity:** O(N) where N is the total number of elements in all given sets.

**Since:** 1.0.0

title: Sorted set commands

text:
Sorted set commands operate on sets of unique strings ordered by a score.

BZMPOP - Removes and returns a member by score from one or more sorted sets. Blocks until a member is available otherwise. Deletes the sorted set if the last element was popped.

**Syntax:** `BZMPOP timeout numkeys key [key ...] <MIN | MAX> [COUNT count]`

**Description:** Removes and returns a member by score from one or more sorted sets. Blocks until a member is available otherwise. Deletes the sorted set if the last element was popped.

**Complexity:** O(K) + O(M*log(N)) where K is the number of provided keys, N being the number of elements in the sorted set, and M being the number of elements popped.

**Since:** 7.0.0

BZPOPMAX - Removes and returns the member with the highest score from one or more sorted sets. Blocks until a member available otherwise.  Deletes the sorted set if the last element was popped.

**Syntax:** `BZPOPMAX key [key ...] timeout`

**Description:** Removes and returns the member with the highest score from one or more sorted sets. Blocks until a member available otherwise.  Deletes the sorted set if the last element was popped.

**Complexity:** O(log(N)) with N being the number of elements in the sorted set.

**Since:** 5.0.0

BZPOPMIN - Removes and returns the member with the lowest score from one or more sorted sets. Blocks until a member is available otherwise. Deletes the sorted set if the last element was popped.

**Syntax:** `BZPOPMIN key [key ...] timeout`

**Description:** Removes and returns the member with the lowest score from one or more sorted sets. Blocks until a member is available otherwise. Deletes the sorted set if the last element was popped.

**Complexity:** O(log(N)) with N being the number of elements in the sorted set.

**Since:** 5.0.0

ZADD - Adds one or more members to a sorted set, or updates their scores. Creates the key if it doesn't exist.

**Syntax:** `ZADD key [NX | XX] [GT | LT] [CH] [INCR] score member [score member
  ...]`

**Description:** Adds one or more members to a sorted set, or updates their scores. Creates the key if it doesn't exist.

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

**Since:** 1.2.0

ZCARD - Returns the number of members in a sorted set.

**Syntax:** `ZCARD key`

**Description:** Returns the number of members in a sorted set.

**Complexity:** O(1)

**Since:** 1.2.0

ZCOUNT - Returns the count of members in a sorted set that have scores within a range.

**Syntax:** `ZCOUNT key min max`

**Description:** Returns the count of members in a sorted set that have scores within a range.

**Complexity:** O(log(N)) with N being the number of elements in the sorted set.

**Since:** 2.0.0

ZDIFF - Returns the difference between multiple sorted sets.

**Syntax:** `ZDIFF numkeys key [key ...] [WITHSCORES]`

**Description:** Returns the difference between multiple sorted sets.

**Complexity:** O(L + (N-K)log(N)) worst case where L is the total number of elements in all the sets, N is the size of the first set, and K is the size of the result set.

**Since:** 6.2.0

ZDIFFSTORE - Stores the difference of multiple sorted sets in a key.

**Syntax:** `ZDIFFSTORE destination numkeys key [key ...]`

**Description:** Stores the difference of multiple sorted sets in a key.

**Complexity:** O(L + (N-K)log(N)) worst case where L is the total number of elements in all the sets, N is the size of the first set, and K is the size of the result set.

**Since:** 6.2.0

ZINCRBY - Increments the score of a member in a sorted set.

**Syntax:** `ZINCRBY key increment member`

**Description:** Increments the score of a member in a sorted set.

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

**Since:** 1.2.0

ZINTER - Returns the intersect of multiple sorted sets.

**Syntax:** `ZINTER numkeys key [key ...] [WEIGHTS weight [weight ...]]
  [AGGREGATE <SUM | MIN | MAX>] [WITHSCORES]`

**Description:** Returns the intersect of multiple sorted sets.

**Complexity:** O(N*K)+O(M*log(M)) worst case with N being the smallest input sorted set, K being the number of input sorted sets and M being the number of elements in the resulting sorted set.

**Since:** 6.2.0

ZINTERCARD - Returns the number of members of the intersect of multiple sorted sets.

**Syntax:** `ZINTERCARD numkeys key [key ...] [LIMIT limit]`

**Description:** Returns the number of members of the intersect of multiple sorted sets.

**Complexity:** O(N*K) worst case with N being the smallest input sorted set, K being the number of input sorted sets.

**Since:** 7.0.0

ZINTERSTORE - Stores the intersect of multiple sorted sets in a key.

**Syntax:** `ZINTERSTORE destination numkeys key [key ...] [WEIGHTS weight
  [weight ...]] [AGGREGATE <SUM | MIN | MAX>]`

**Description:** Stores the intersect of multiple sorted sets in a key.

**Complexity:** O(N*K)+O(M*log(M)) worst case with N being the smallest input sorted set, K being the number of input sorted sets and M being the number of elements in the resulting sorted set.

**Since:** 2.0.0

ZLEXCOUNT - Returns the number of members in a sorted set within a lexicographical range.

**Syntax:** `ZLEXCOUNT key min max`

**Description:** Returns the number of members in a sorted set within a lexicographical range.

**Complexity:** O(log(N)) with N being the number of elements in the sorted set.

**Since:** 2.8.9

ZMPOP - Returns the highest- or lowest-scoring members from one or more sorted sets after removing them. Deletes the sorted set if the last member was popped.

**Syntax:** `ZMPOP numkeys key [key ...] <MIN | MAX> [COUNT count]`

**Description:** Returns the highest- or lowest-scoring members from one or more sorted sets after removing them. Deletes the sorted set if the last member was popped.

**Complexity:** O(K) + O(M*log(N)) where K is the number of provided keys, N being the number of elements in the sorted set, and M being the number of elements popped.

**Since:** 7.0.0

ZMSCORE - Returns the score of one or more members in a sorted set.

**Syntax:** `ZMSCORE key member [member ...]`

**Description:** Returns the score of one or more members in a sorted set.

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

**Since:** 6.2.0

ZPOPMAX - Returns the highest-scoring members from a sorted set after removing them. Deletes the sorted set if the last member was popped.

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

**Description:** Returns the highest-scoring members from a sorted set after removing them. Deletes the sorted set if the last member was popped.

**Complexity:** O(log(N)*M) with N being the number of elements in the sorted set, and M being the number of elements popped.

**Since:** 5.0.0

ZPOPMIN - Returns the lowest-scoring members from a sorted set after removing them. Deletes the sorted set if the last member was popped.

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

**Description:** Returns the lowest-scoring members from a sorted set after removing them. Deletes the sorted set if the last member was popped.

**Complexity:** O(log(N)*M) with N being the number of elements in the sorted set, and M being the number of elements popped.

**Since:** 5.0.0

ZRANDMEMBER - Returns one or more random members from a sorted set.

**Syntax:** `ZRANDMEMBER key [count [WITHSCORES]]`

**Description:** Returns one or more random members from a sorted set.

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

**Since:** 6.2.0

ZRANGE - Returns members in a sorted set within a range of indexes.

**Syntax:** `ZRANGE key start stop [BYSCORE | BYLEX] [REV] [LIMIT offset count]
  [WITHSCORES]`

**Description:** Returns members in a sorted set within a range of indexes.

**Complexity:** O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements returned.

**Since:** 1.2.0

ZRANGEBYLEX - Returns members in a sorted set within a lexicographical range.

**Syntax:** `ZRANGEBYLEX key min max [LIMIT offset count]`

**Description:** Returns members in a sorted set within a lexicographical range.

**Complexity:** O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).

**Since:** 2.8.9

ZRANGEBYSCORE - Returns members in a sorted set within a range of scores.

**Syntax:** `ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]`

**Description:** Returns members in a sorted set within a range of scores.

**Complexity:** O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).

**Since:** 1.0.5

ZRANGESTORE - Stores a range of members from sorted set in a key.

**Syntax:** `ZRANGESTORE dst src min max [BYSCORE | BYLEX] [REV] [LIMIT offset
  count]`

**Description:** Stores a range of members from sorted set in a key.

**Complexity:** O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements stored into the destination key.

**Since:** 6.2.0

ZRANK - Returns the index of a member in a sorted set ordered by ascending scores.

**Syntax:** `ZRANK key member [WITHSCORE]`

**Description:** Returns the index of a member in a sorted set ordered by ascending scores.

**Complexity:** O(log(N))

**Since:** 2.0.0

ZREM - Removes one or more members from a sorted set. Deletes the sorted set if all members were removed.

**Syntax:** `ZREM key member [member ...]`

**Description:** Removes one or more members from a sorted set. Deletes the sorted set if all members were removed.

**Complexity:** O(M*log(N)) with N being the number of elements in the sorted set and M the number of elements to be removed.

**Since:** 1.2.0

ZREMRANGEBYLEX - Removes members in a sorted set within a lexicographical range. Deletes the sorted set if all members were removed.

**Syntax:** `ZREMRANGEBYLEX key min max`

**Description:** Removes members in a sorted set within a lexicographical range. Deletes the sorted set if all members were removed.

**Complexity:** O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements removed by the operation.

**Since:** 2.8.9

ZREMRANGEBYRANK - Removes members in a sorted set within a range of indexes. Deletes the sorted set if all members were removed.

**Syntax:** `ZREMRANGEBYRANK key start stop`

**Description:** Removes members in a sorted set within a range of indexes. Deletes the sorted set if all members were removed.

**Complexity:** O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements removed by the operation.

**Since:** 2.0.0

ZREMRANGEBYSCORE - Removes members in a sorted set within a range of scores. Deletes the sorted set if all members were removed.

**Syntax:** `ZREMRANGEBYSCORE key min max`

**Description:** Removes members in a sorted set within a range of scores. Deletes the sorted set if all members were removed.

**Complexity:** O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements removed by the operation.

**Since:** 1.2.0

ZREVRANGE - Returns members in a sorted set within a range of indexes in reverse order.

**Syntax:** `ZREVRANGE key start stop [WITHSCORES]`

**Description:** Returns members in a sorted set within a range of indexes in reverse order.

**Complexity:** O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements returned.

**Since:** 1.2.0

ZREVRANGEBYLEX - Returns members in a sorted set within a lexicographical range in reverse order.

**Syntax:** `ZREVRANGEBYLEX key max min [LIMIT offset count]`

**Description:** Returns members in a sorted set within a lexicographical range in reverse order.

**Complexity:** O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).

**Since:** 2.8.9

ZREVRANGEBYSCORE - Returns members in a sorted set within a range of scores in reverse order.

**Syntax:** `ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count]`

**Description:** Returns members in a sorted set within a range of scores in reverse order.

**Complexity:** O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).

**Since:** 2.2.0

ZREVRANK - Returns the index of a member in a sorted set ordered by descending scores.

**Syntax:** `ZREVRANK key member [WITHSCORE]`

**Description:** Returns the index of a member in a sorted set ordered by descending scores.

**Complexity:** O(log(N))

**Since:** 2.0.0

ZSCAN - Iterates over members and scores of a sorted set.

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

**Description:** Iterates over members and scores of a sorted set.

**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

ZSCORE - Returns the score of a member in a sorted set.

**Syntax:** `ZSCORE key member`

**Description:** Returns the score of a member in a sorted set.

**Complexity:** O(1)

**Since:** 1.2.0

ZUNION - Returns the union of multiple sorted sets.

**Syntax:** `ZUNION numkeys key [key ...] [WEIGHTS weight [weight ...]]
  [AGGREGATE <SUM | MIN | MAX>] [WITHSCORES]`

**Description:** Returns the union of multiple sorted sets.

**Complexity:** O(N)+O(M*log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set.

**Since:** 6.2.0

ZUNIONSTORE - Stores the union of multiple sorted sets in a key.

**Syntax:** `ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight
  [weight ...]] [AGGREGATE <SUM | MIN | MAX>]`

**Description:** Stores the union of multiple sorted sets in a key.

**Complexity:** O(N)+O(M log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set.

**Since:** 2.0.0

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

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

**Syntax:** `XADD key [NOMKSTREAM] [KEEPREF | DELREF | ACKED] [<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

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

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:**

**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

title: HyperLogLog commands

title: Geospatial commands

text:
Geospatial commands operate on geographic coordinates.

GEOADD - Adds one or more members to a geospatial index. The key is created if it doesn't exist.

**Syntax:** `GEOADD key [NX | XX] [CH] longitude latitude member [longitude
  latitude member ...]`

**Description:** Adds one or more members to a geospatial index. The key is created if it doesn't exist.

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

**Since:** 3.2.0

GEODIST - Returns the distance between two members of a geospatial index.

**Syntax:** `GEODIST key member1 member2 [M | KM | FT | MI]`

**Description:** Returns the distance between two members of a geospatial index.

**Complexity:** O(1)

**Since:** 3.2.0

GEOHASH - Returns members from a geospatial index as geohash strings.

**Syntax:** `GEOHASH key [member [member ...]]`

**Description:** Returns members from a geospatial index as geohash strings.

**Complexity:** O(1) for each member requested.

**Since:** 3.2.0

GEOPOS - Returns the longitude and latitude of members from a geospatial index.

**Syntax:** `GEOPOS key [member [member ...]]`

**Description:** Returns the longitude and latitude of members from a geospatial index.

**Complexity:** O(1) for each member requested.

**Since:** 3.2.0

GEORADIUS - Queries a geospatial index for members within a distance from a coordinate, optionally stores the result.

**Syntax:** `GEORADIUS key longitude latitude radius <M | KM | FT | MI>
  [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count [ANY]] [ASC | DESC]
  [STORE key | STOREDIST key]`

**Description:** Queries a geospatial index for members within a distance from a coordinate, optionally stores the result.

**Complexity:** O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.

**Since:** 3.2.0

GEORADIUSBYMEMBER - Queries a geospatial index for members within a distance from a member, optionally stores the result.

**Syntax:** `GEORADIUSBYMEMBER key member radius <M | KM | FT | MI> [WITHCOORD]
  [WITHDIST] [WITHHASH] [COUNT count [ANY]] [ASC | DESC] [STORE key
  | STOREDIST key]`

**Description:** Queries a geospatial index for members within a distance from a member, optionally stores the result.

**Complexity:** O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.

**Since:** 3.2.0

GEORADIUSBYMEMBER_RO - Returns members from a geospatial index that are within a distance from a member.

**Syntax:** `GEORADIUSBYMEMBER RO key member radius <M | KM | FT | MI>
  [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count [ANY]] [ASC | DESC]`

**Description:** Returns members from a geospatial index that are within a distance from a member.

**Complexity:** O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.

**Since:** 3.2.10

GEORADIUS_RO - Returns members from a geospatial index that are within a distance from a coordinate.

**Syntax:** `GEORADIUS RO key longitude latitude radius <M | KM | FT | MI>
  [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count [ANY]] [ASC | DESC]`

**Description:** Returns members from a geospatial index that are within a distance from a coordinate.

**Complexity:** O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.

**Since:** 3.2.10

GEOSEARCH - Queries a geospatial index for members inside an area of a box or a circle.

**Syntax:** `GEOSEARCH key <FROMMEMBER member | FROMLONLAT longitude latitude>
  <BYRADIUS radius <M | KM | FT | MI> | BYBOX width height <M | KM |
  FT | MI>> [ASC | DESC] [COUNT count [ANY]] [WITHCOORD] [WITHDIST]
  [WITHHASH]`

**Description:** Queries a geospatial index for members inside an area of a box or a circle.

**Complexity:** O(N+log(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape

**Since:** 6.2.0

GEOSEARCHSTORE - Queries a geospatial index for members inside an area of a box or a circle, optionally stores the result.

**Syntax:** `GEOSEARCHSTORE destination source <FROMMEMBER member |
  FROMLONLAT longitude latitude> <BYRADIUS radius <M | KM | FT | MI>
  | BYBOX width height <M | KM | FT | MI>> [ASC | DESC] [COUNT count
  [ANY]] [STOREDIST]`

**Description:** Queries a geospatial index for members inside an area of a box or a circle, optionally stores the result.

**Complexity:** O(N+log(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape

**Since:** 6.2.0

title: JSON commands

title: Search commands

title: Time series commands

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. ⭐ New in 8.0

**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. ⭐ New in 8.0

**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. ⭐ New in 8.0

**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. ⭐ New in 8.0

**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. ⭐ New in 8.0

**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. ⭐ New in 8.0

**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. ⭐ New in 8.0

**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. ⭐ New in 8.0

**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. ⭐ New in 8.0

**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

VREM - Remove an element from a vector set. ⭐ New in 8.0

**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. ⭐ New in 8.0

**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. ⭐ New in 8.0

**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

text:
Pub/Sub commands enable message passing between clients.

PSUBSCRIBE - Listens for messages published to channels that match one or more patterns.

**Syntax:** `PSUBSCRIBE pattern [pattern ...]`

**Description:** Listens for messages published to channels that match one or more patterns.

**Complexity:** O(N) where N is the number of patterns to subscribe to.

**Since:** 2.0.0

PUBLISH - Posts a message to a channel.

**Syntax:** `PUBLISH channel message`

**Description:** Posts a message to a channel.

**Complexity:** O(N+M) where N is the number of clients subscribed to the receiving channel and M is the total number of subscribed patterns (by any client).

**Since:** 2.0.0

PUBSUB CHANNELS - Returns the active channels.

**Syntax:** `PUBSUB CHANNELS [pattern]`

**Description:** Returns the active channels.

**Complexity:** O(N) where N is the number of active channels, and assuming constant time pattern matching (relatively short channels and patterns)

**Since:** 2.8.0

PUBSUB NUMPAT - Returns a count of unique pattern subscriptions.

**Syntax:** `PUBSUB NUMPAT`

**Description:** Returns a count of unique pattern subscriptions.

**Complexity:** O(1)

**Since:** 2.8.0

PUBSUB NUMSUB - Returns a count of subscribers to channels.

**Syntax:** `PUBSUB NUMSUB [channel [channel ...]]`

**Description:** Returns a count of subscribers to channels.

**Complexity:** O(N) for the NUMSUB subcommand, where N is the number of requested channels

**Since:** 2.8.0

PUBSUB SHARDCHANNELS - Returns the active shard channels.

**Syntax:** `PUBSUB SHARDCHANNELS [pattern]`

**Description:** Returns the active shard channels.

**Complexity:** O(N) where N is the number of active shard channels, and assuming constant time pattern matching (relatively short shard channels).

**Since:** 7.0.0

PUBSUB SHARDNUMSUB - Returns the count of subscribers of shard channels.

**Syntax:** `PUBSUB SHARDNUMSUB [shardchannel [shardchannel ...]]`

**Description:** Returns the count of subscribers of shard channels.

**Complexity:** O(N) for the SHARDNUMSUB subcommand, where N is the number of requested shard channels

**Since:** 7.0.0

PUNSUBSCRIBE - Stops listening to messages published to channels that match one or more patterns.

**Syntax:** `PUNSUBSCRIBE [pattern [pattern ...]]`

**Description:** Stops listening to messages published to channels that match one or more patterns.

**Complexity:** O(N) where N is the number of patterns to unsubscribe.

**Since:** 2.0.0

SPUBLISH - Post a message to a shard channel

**Syntax:** `SPUBLISH shardchannel message`

**Description:** Post a message to a shard channel

**Complexity:** O(N) where N is the number of clients subscribed to the receiving shard channel.

**Since:** 7.0.0

SSUBSCRIBE - Listens for messages published to shard channels.

**Syntax:** `SSUBSCRIBE shardchannel [shardchannel ...]`

**Description:** Listens for messages published to shard channels.

**Complexity:** O(N) where N is the number of shard channels to subscribe to.

**Since:** 7.0.0

SUBSCRIBE - Listens for messages published to channels.

**Syntax:** `SUBSCRIBE channel [channel ...]`

**Description:** Listens for messages published to channels.

**Complexity:** O(N) where N is the number of channels to subscribe to.

**Since:** 2.0.0

SUNSUBSCRIBE - Stops listening to messages posted to shard channels.

**Syntax:** `SUNSUBSCRIBE [shardchannel [shardchannel ...]]`

**Description:** Stops listening to messages posted to shard channels.

**Complexity:** O(N) where N is the number of shard channels to unsubscribe.

**Since:** 7.0.0

UNSUBSCRIBE - Stops listening to messages posted to channels.

**Syntax:** `UNSUBSCRIBE [channel [channel ...]]`

**Description:** Stops listening to messages posted to channels.

**Complexity:** O(N) where N is the number of channels to unsubscribe.

**Since:** 2.0.0

title: Transaction commands

title: Scripting commands

text:
Scripting commands enable server-side Lua script execution.

EVAL - Executes a server-side Lua script.

**Syntax:** `EVAL script numkeys [key [key ...]] [arg [arg ...]]`

**Description:** Executes a server-side Lua script.

**Complexity:** Depends on the script that is executed.

**Since:** 2.6.0

EVALSHA - Executes a server-side Lua script by SHA1 digest.

**Syntax:** `EVALSHA sha1 numkeys [key [key ...]] [arg [arg ...]]`

**Description:** Executes a server-side Lua script by SHA1 digest.

**Complexity:** Depends on the script that is executed.

**Since:** 2.6.0

EVALSHA_RO - Executes a read-only server-side Lua script by SHA1 digest.

**Syntax:** `EVALSHA RO sha1 numkeys [key [key ...]] [arg [arg ...]]`

**Description:** Executes a read-only server-side Lua script by SHA1 digest.

**Complexity:** Depends on the script that is executed.

**Since:** 7.0.0

EVAL_RO - Executes a read-only server-side Lua script.

**Syntax:** `EVAL RO script numkeys [key [key ...]] [arg [arg ...]]`

**Description:** Executes a read-only server-side Lua script.

**Complexity:** Depends on the script that is executed.

**Since:** 7.0.0

FCALL - Invokes a function.

**Syntax:** `FCALL function numkeys [key [key ...]] [arg [arg ...]]`

**Description:** Invokes a function.

**Complexity:** Depends on the function that is executed.

**Since:** 7.0.0

FCALL_RO - Invokes a read-only function.

**Syntax:** `FCALL RO function numkeys [key [key ...]] [arg [arg ...]]`

**Description:** Invokes a read-only function.

**Complexity:** Depends on the function that is executed.

**Since:** 7.0.0

FUNCTION DELETE - Deletes a library and its functions.

**Syntax:** `FUNCTION DELETE library-name`

**Description:** Deletes a library and its functions.

**Complexity:** O(1)

**Since:** 7.0.0

FUNCTION DUMP - Dumps all libraries into a serialized binary payload.

**Syntax:** `FUNCTION DUMP`

**Description:** Dumps all libraries into a serialized binary payload.

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

**Since:** 7.0.0

FUNCTION FLUSH - Deletes all libraries and functions.

**Syntax:** `FUNCTION FLUSH [ASYNC | SYNC]`

**Description:** Deletes all libraries and functions.

**Complexity:** O(N) where N is the number of functions deleted

**Since:** 7.0.0

FUNCTION KILL - Terminates a function during execution.

**Syntax:** `FUNCTION KILL`

**Description:** Terminates a function during execution.

**Complexity:** O(1)

**Since:** 7.0.0

FUNCTION LIST - Returns information about all libraries.

**Syntax:** `FUNCTION LIST [LIBRARYNAME library-name-pattern] [WITHCODE]`

**Description:** Returns information about all libraries.

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

**Since:** 7.0.0

FUNCTION LOAD - Creates a library.

**Syntax:** `FUNCTION LOAD [REPLACE] function-code`

**Description:** Creates a library.

**Complexity:** O(1) (considering compilation time is redundant)

**Since:** 7.0.0

FUNCTION RESTORE - Restores all libraries from a payload.

**Syntax:** `FUNCTION RESTORE serialized-value [FLUSH | APPEND | REPLACE]`

**Description:** Restores all libraries from a payload.

**Complexity:** O(N) where N is the number of functions on the payload

**Since:** 7.0.0

FUNCTION STATS - Returns information about a function during execution.

**Syntax:** `FUNCTION STATS`

**Description:** Returns information about a function during execution.

**Complexity:** O(1)

**Since:** 7.0.0

SCRIPT DEBUG - Sets the debug mode of server-side Lua scripts.

**Syntax:** `SCRIPT DEBUG <YES | SYNC | NO>`

**Description:** Sets the debug mode of server-side Lua scripts.

**Complexity:** O(1)

**Since:** 3.2.0

SCRIPT EXISTS - Determines whether server-side Lua scripts exist in the script cache.

**Syntax:** `SCRIPT EXISTS sha1 [sha1 ...]`

**Description:** Determines whether server-side Lua scripts exist in the script cache.

**Complexity:** O(N) with N being the number of scripts to check (so checking a single script is an O(1) operation).

**Since:** 2.6.0

SCRIPT FLUSH - Removes all server-side Lua scripts from the script cache.

**Syntax:** `SCRIPT FLUSH [ASYNC | SYNC]`

**Description:** Removes all server-side Lua scripts from the script cache.

**Complexity:** O(N) with N being the number of scripts in cache

**Since:** 2.6.0

SCRIPT KILL - Terminates a server-side Lua script during execution.

**Syntax:** `SCRIPT KILL`

**Description:** Terminates a server-side Lua script during execution.

**Complexity:** O(1)

**Since:** 2.6.0

SCRIPT LOAD - Loads a server-side Lua script to the script cache.

**Syntax:** `SCRIPT LOAD script`

**Description:** Loads a server-side Lua script to the script cache.

**Complexity:** O(N) with N being the length in bytes of the script body.

**Since:** 2.6.0

title: Connection commands

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

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

title: Generic commands