diff --git a/content/commands/bitop.md b/content/commands/bitop.md index bad4c53d8d..1c5e027f8f 100644 --- a/content/commands/bitop.md +++ b/content/commands/bitop.md @@ -82,6 +82,11 @@ summary: Performs bitwise operations on multiple strings, and stores the result. syntax_fmt: BITOP destkey key [key ...] title: BITOP --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Perform a bitwise operation between multiple keys (containing string values) and store the result in the destination key. diff --git a/content/commands/blmove.md b/content/commands/blmove.md index 8df731cfbe..eba55921ee 100644 --- a/content/commands/blmove.md +++ b/content/commands/blmove.md @@ -94,6 +94,11 @@ summary: Pops an element from a list, pushes it to another list and returns it. syntax_fmt: BLMOVE source destination timeout title: BLMOVE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + `BLMOVE` is the blocking variant of [`LMOVE`]({{< relref "/commands/lmove" >}}). When `source` contains elements, this command behaves exactly like [`LMOVE`]({{< relref "/commands/lmove" >}}). When used inside a [`MULTI`]({{< relref "/commands/multi" >}})/[`EXEC`]({{< relref "/commands/exec" >}}) block or a Lua script, this command behaves exactly like [`LMOVE`]({{< relref "/commands/lmove" >}}). diff --git a/content/commands/blmpop.md b/content/commands/blmpop.md index a457910e5c..6bc42aa304 100644 --- a/content/commands/blmpop.md +++ b/content/commands/blmpop.md @@ -75,6 +75,11 @@ summary: Pops the first element from one of multiple lists. Blocks until an elem syntax_fmt: "BLMPOP timeout numkeys key [key ...] [COUNT\_count]" title: BLMPOP --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + `BLMPOP` is the blocking variant of [`LMPOP`]({{< relref "/commands/lmpop" >}}). When any of the lists contains elements, this command behaves exactly like [`LMPOP`]({{< relref "/commands/lmpop" >}}). diff --git a/content/commands/blpop.md b/content/commands/blpop.md index ba2504b9b3..73939fc65c 100644 --- a/content/commands/blpop.md +++ b/content/commands/blpop.md @@ -57,6 +57,11 @@ summary: Removes and returns the first element in a list. Blocks until an elemen syntax_fmt: BLPOP key [key ...] timeout title: BLPOP --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + `BLPOP` is a blocking list pop primitive. It is the blocking version of [`LPOP`]({{< relref "/commands/lpop" >}}) because it blocks the connection when there are no elements to pop from any of the given lists. diff --git a/content/commands/brpop.md b/content/commands/brpop.md index ba3eb96335..cdbc8c4bbe 100644 --- a/content/commands/brpop.md +++ b/content/commands/brpop.md @@ -57,6 +57,11 @@ summary: Removes and returns the last element in a list. Blocks until an element syntax_fmt: BRPOP key [key ...] timeout title: BRPOP --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + `BRPOP` is a blocking list pop primitive. It is the blocking version of [`RPOP`]({{< relref "/commands/rpop" >}}) because it blocks the connection when there are no elements to pop from any of the given lists. diff --git a/content/commands/brpoplpush.md b/content/commands/brpoplpush.md index 6bc1a9640b..9fe0a1e14b 100644 --- a/content/commands/brpoplpush.md +++ b/content/commands/brpoplpush.md @@ -79,6 +79,11 @@ summary: Pops an element from a list, pushes it to another list and returns it. syntax_fmt: BRPOPLPUSH source destination timeout title: BRPOPLPUSH --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + `BRPOPLPUSH` is the blocking variant of [`RPOPLPUSH`]({{< relref "/commands/rpoplpush" >}}). When `source` contains elements, this command behaves exactly like [`RPOPLPUSH`]({{< relref "/commands/rpoplpush" >}}). When used inside a [`MULTI`]({{< relref "/commands/multi" >}})/[`EXEC`]({{< relref "/commands/exec" >}}) block or a Lua script, this command behaves exactly like [`RPOPLPUSH`]({{< relref "/commands/rpoplpush" >}}). diff --git a/content/commands/bzmpop.md b/content/commands/bzmpop.md index 599a26049e..ce0c6c3b59 100644 --- a/content/commands/bzmpop.md +++ b/content/commands/bzmpop.md @@ -77,6 +77,11 @@ summary: Removes and returns a member by score from one or more sorted sets. Blo syntax_fmt: "BZMPOP timeout numkeys key [key ...] [COUNT\_count]" title: BZMPOP --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + `BZMPOP` is the blocking variant of [`ZMPOP`]({{< relref "/commands/zmpop" >}}). When any of the sorted sets contains elements, this command behaves exactly like [`ZMPOP`]({{< relref "/commands/zmpop" >}}). diff --git a/content/commands/bzpopmax.md b/content/commands/bzpopmax.md index d38f5f5acb..a1ec2faabe 100644 --- a/content/commands/bzpopmax.md +++ b/content/commands/bzpopmax.md @@ -60,6 +60,11 @@ summary: Removes and returns the member with the highest score from one or more syntax_fmt: BZPOPMAX key [key ...] timeout title: BZPOPMAX --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + `BZPOPMAX` is the blocking variant of the sorted set [`ZPOPMAX`]({{< relref "/commands/zpopmax" >}}) primitive. It is the blocking version because it blocks the connection when there are no diff --git a/content/commands/bzpopmin.md b/content/commands/bzpopmin.md index 14f4f57041..fe43ff3d7d 100644 --- a/content/commands/bzpopmin.md +++ b/content/commands/bzpopmin.md @@ -60,6 +60,11 @@ summary: Removes and returns the member with the lowest score from one or more s syntax_fmt: BZPOPMIN key [key ...] timeout title: BZPOPMIN --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + `BZPOPMIN` is the blocking variant of the sorted set [`ZPOPMIN`]({{< relref "/commands/zpopmin" >}}) primitive. It is the blocking version because it blocks the connection when there are no diff --git a/content/commands/cms.merge.md b/content/commands/cms.merge.md index 289bd1a9fc..545f05f127 100644 --- a/content/commands/cms.merge.md +++ b/content/commands/cms.merge.md @@ -44,6 +44,11 @@ syntax_fmt: "CMS.MERGE destination numKeys source [source ...] [WEIGHTS weight\n \ [weight ...]]" title: CMS.MERGE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Merges several sketches into one sketch. All sketches must have identical width and depth. Weights can be used to multiply certain sketches. Default weight is 1. ### Parameters: diff --git a/content/commands/copy.md b/content/commands/copy.md index b6b74b9f00..9b729ef97b 100644 --- a/content/commands/copy.md +++ b/content/commands/copy.md @@ -73,6 +73,11 @@ summary: Copies the value of a key to a new key. syntax_fmt: "COPY source destination [DB\_destination-db] [REPLACE]" title: COPY --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + This command copies the value stored at the `source` key to the `destination` key. diff --git a/content/commands/dbsize.md b/content/commands/dbsize.md index fcfffe5258..665e755f51 100644 --- a/content/commands/dbsize.md +++ b/content/commands/dbsize.md @@ -31,6 +31,11 @@ summary: Returns the number of keys in the database. syntax_fmt: DBSIZE title: DBSIZE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Return the number of keys in the currently-selected database. ## Redis Enterprise and Redis Cloud compatibility diff --git a/content/commands/del.md b/content/commands/del.md index 5478f1030f..7fb63f8825 100644 --- a/content/commands/del.md +++ b/content/commands/del.md @@ -52,6 +52,11 @@ summary: Deletes one or more keys. syntax_fmt: DEL key [key ...] title: DEL --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Removes the specified keys. A key is ignored if it does not exist. diff --git a/content/commands/eval.md b/content/commands/eval.md index c3e20a9420..69a694659e 100644 --- a/content/commands/eval.md +++ b/content/commands/eval.md @@ -63,6 +63,11 @@ summary: Executes a server-side Lua script. syntax_fmt: EVAL script numkeys [key [key ...]] [arg [arg ...]] title: EVAL --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Invoke the execution of a server-side Lua script. The first argument is the script's source code. diff --git a/content/commands/evalsha.md b/content/commands/evalsha.md index 85d5d44e6b..4cbcf7727a 100644 --- a/content/commands/evalsha.md +++ b/content/commands/evalsha.md @@ -62,6 +62,11 @@ summary: Executes a server-side Lua script by SHA1 digest. syntax_fmt: EVALSHA sha1 numkeys [key [key ...]] [arg [arg ...]] title: EVALSHA --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Evaluate a script from the server's cache by its SHA1 digest. The server caches scripts by using the [`SCRIPT LOAD`]({{< relref "/commands/script-load" >}}) command. diff --git a/content/commands/exec.md b/content/commands/exec.md index f183215707..81737e6a2d 100644 --- a/content/commands/exec.md +++ b/content/commands/exec.md @@ -29,6 +29,11 @@ summary: Executes all commands in a transaction. syntax_fmt: EXEC title: EXEC --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Executes all previously queued commands in a [transaction][tt] and restores the connection state to normal. diff --git a/content/commands/exists.md b/content/commands/exists.md index 43813fa3fc..c80617781f 100644 --- a/content/commands/exists.md +++ b/content/commands/exists.md @@ -52,6 +52,11 @@ summary: Determines whether one or more keys exist. syntax_fmt: EXISTS key [key ...] title: EXISTS --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Returns if `key` exists. The user should be aware that if the same existing key is mentioned in the arguments multiple times, it will be counted multiple times. So if `somekey` exists, `EXISTS somekey somekey` will return 2. diff --git a/content/commands/flushall.md b/content/commands/flushall.md index 48737be141..fe004c0506 100644 --- a/content/commands/flushall.md +++ b/content/commands/flushall.md @@ -51,6 +51,11 @@ summary: Removes all keys from all databases. syntax_fmt: FLUSHALL [ASYNC | SYNC] title: FLUSHALL --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Delete all the keys of all the existing databases, not just the currently selected one. This command never fails. diff --git a/content/commands/flushdb.md b/content/commands/flushdb.md index 0f7bfc01d4..489c7254f4 100644 --- a/content/commands/flushdb.md +++ b/content/commands/flushdb.md @@ -51,6 +51,11 @@ summary: Remove all keys from the current database. syntax_fmt: FLUSHDB [ASYNC | SYNC] title: FLUSHDB --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Delete all the keys of the currently selected DB. This command never fails. diff --git a/content/commands/georadius.md b/content/commands/georadius.md index 0274033793..a4f9fc9a62 100644 --- a/content/commands/georadius.md +++ b/content/commands/georadius.md @@ -171,6 +171,11 @@ syntax_fmt: "GEORADIUS key longitude latitude radius \n [WITH key]" title: GEORADIUS --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Return the members of a sorted set populated with geospatial information using [`GEOADD`]({{< relref "/commands/geoadd" >}}), which are within the borders of the area specified with the center location and the maximum distance from the center (the radius). This manual page also covers the [`GEORADIUS_RO`]({{< relref "/commands/georadius_ro" >}}) and [`GEORADIUSBYMEMBER_RO`]({{< relref "/commands/georadiusbymember_ro" >}}) variants (see the section below for more information). diff --git a/content/commands/georadiusbymember.md b/content/commands/georadiusbymember.md index 7666c79068..adfcdc2810 100644 --- a/content/commands/georadiusbymember.md +++ b/content/commands/georadiusbymember.md @@ -168,6 +168,11 @@ syntax_fmt: "GEORADIUSBYMEMBER key member radius [WITHCOORD]\ key]" title: GEORADIUSBYMEMBER --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + This command is exactly like [`GEORADIUS`]({{< relref "/commands/georadius" >}}) with the sole difference that instead of taking, as the center of the area to query, a longitude and latitude value, it takes the name of a member already existing inside the geospatial index represented by the sorted set. diff --git a/content/commands/geosearchstore.md b/content/commands/geosearchstore.md index c4c92f39f6..cb424f2537 100644 --- a/content/commands/geosearchstore.md +++ b/content/commands/geosearchstore.md @@ -176,6 +176,11 @@ syntax_fmt: "GEOSEARCHSTORE destination source > [ASC | DESC] [COUNT\_count\n [ANY]] [STOREDIST]" title: GEOSEARCHSTORE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + This command is like [`GEOSEARCH`]({{< relref "/commands/geosearch" >}}), but stores the result in destination key. This command replaces the now deprecated [`GEORADIUS`]({{< relref "/commands/georadius" >}}) and [`GEORADIUSBYMEMBER`]({{< relref "/commands/georadiusbymember" >}}). diff --git a/content/commands/json.mget.md b/content/commands/json.mget.md index c5528a809f..45a7d3aa28 100644 --- a/content/commands/json.mget.md +++ b/content/commands/json.mget.md @@ -34,6 +34,11 @@ summary: Returns the values at a path from one or more keys syntax_fmt: JSON.MGET key [key ...] path title: JSON.MGET --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Return the values at `path` from multiple `key` arguments {{% warning %}} diff --git a/content/commands/json.mset.md b/content/commands/json.mset.md index e9938cdbc7..d85a46401b 100644 --- a/content/commands/json.mset.md +++ b/content/commands/json.mset.md @@ -41,6 +41,11 @@ summary: Sets or updates the JSON value of one or more keys syntax_fmt: JSON.MSET key path value [key path value ...] title: JSON.MSET --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Set or update one or more JSON values according to the specified `key`-`path`-`value` triplets `JSON.MSET` is atomic, hence, all given additions or updates are either applied or not. It is not possible for clients to see that some of the keys were updated while others are unchanged. diff --git a/content/commands/keys.md b/content/commands/keys.md index 7073c7acaa..ced85fc925 100644 --- a/content/commands/keys.md +++ b/content/commands/keys.md @@ -36,6 +36,11 @@ summary: Returns all key names that match a pattern. syntax_fmt: KEYS pattern title: KEYS --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Returns all keys matching `pattern`. While the time complexity for this operation is O(N), the constant times are diff --git a/content/commands/lmove.md b/content/commands/lmove.md index d7cabf1305..0fc0424c86 100644 --- a/content/commands/lmove.md +++ b/content/commands/lmove.md @@ -87,6 +87,11 @@ summary: Returns an element after popping it from one list and pushing it to ano syntax_fmt: LMOVE source destination title: LMOVE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Atomically returns and removes the first/last element (head/tail depending on the `wherefrom` argument) of the list stored at `source`, and pushes the element at the first/last element (head/tail depending on the `whereto` diff --git a/content/commands/lmpop.md b/content/commands/lmpop.md index 52609c9448..b8c9d3b0cb 100644 --- a/content/commands/lmpop.md +++ b/content/commands/lmpop.md @@ -70,6 +70,11 @@ summary: Returns multiple elements from a list after removing them. Deletes the syntax_fmt: "LMPOP numkeys key [key ...] [COUNT\_count]" title: LMPOP --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Pops one or more elements from the first non-empty list key from the list of provided key names. `LMPOP` and [`BLMPOP`]({{< relref "/commands/blmpop" >}}) are similar to the following, more limited, commands: diff --git a/content/commands/mget.md b/content/commands/mget.md index 26e8459469..af9fc9148e 100644 --- a/content/commands/mget.md +++ b/content/commands/mget.md @@ -49,6 +49,10 @@ summary: Atomically returns the string values of one or more keys. syntax_fmt: MGET key [key ...] title: MGET --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + Returns the values of all specified keys. For every key that does not hold a string value or does not exist, the special value `nil` is returned. diff --git a/content/commands/mset.md b/content/commands/mset.md index 69548c2e48..5736ce39db 100644 --- a/content/commands/mset.md +++ b/content/commands/mset.md @@ -56,6 +56,11 @@ summary: Atomically creates or modifies the string values of one or more keys. syntax_fmt: MSET key value [key value ...] title: MSET --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Sets the given keys to their respective values. `MSET` replaces existing values with new values, just as regular [`SET`]({{< relref "/commands/set" >}}). See [`MSETNX`]({{< relref "/commands/msetnx" >}}) if you don't want to overwrite existing values. diff --git a/content/commands/msetnx.md b/content/commands/msetnx.md index a6df44c74d..db0ca73e11 100644 --- a/content/commands/msetnx.md +++ b/content/commands/msetnx.md @@ -55,6 +55,11 @@ summary: Atomically modifies the string values of one or more keys only when all syntax_fmt: MSETNX key value [key value ...] title: MSETNX --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Sets the given keys to their respective values. `MSETNX` will not perform any operation at all even if just a single key already exists. diff --git a/content/commands/multi.md b/content/commands/multi.md index 17ac126ac2..110ea698fa 100644 --- a/content/commands/multi.md +++ b/content/commands/multi.md @@ -30,6 +30,11 @@ summary: Starts a transaction. syntax_fmt: MULTI title: MULTI --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Marks the start of a [transaction][tt] block. Subsequent commands will be queued for atomic execution using [`EXEC`]({{< relref "/commands/exec" >}}). diff --git a/content/commands/pfcount.md b/content/commands/pfcount.md index 91e74a1753..e615f1670a 100644 --- a/content/commands/pfcount.md +++ b/content/commands/pfcount.md @@ -95,6 +95,11 @@ this command are semantically different and have different performances. HyperLogLog representation --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Redis HyperLogLogs are represented using a double representation: the *sparse* representation suitable for HLLs counting a small number of elements (resulting in a small number of registers set to non-zero value), and a *dense* representation suitable for higher cardinalities. Redis automatically switches from the sparse to the dense representation when needed. diff --git a/content/commands/pfmerge.md b/content/commands/pfmerge.md index c1c3573184..d2fed605d1 100644 --- a/content/commands/pfmerge.md +++ b/content/commands/pfmerge.md @@ -65,6 +65,11 @@ summary: Merges one or more HyperLogLog values into a single key. syntax_fmt: PFMERGE destkey [sourcekey [sourcekey ...]] title: PFMERGE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Merge multiple HyperLogLog values into a unique value that will approximate the cardinality of the union of the observed Sets of the source HyperLogLog structures. diff --git a/content/commands/rename.md b/content/commands/rename.md index 1d4199ca42..4836a6dfbe 100644 --- a/content/commands/rename.md +++ b/content/commands/rename.md @@ -62,6 +62,11 @@ summary: Renames a key and overwrites the destination. syntax_fmt: RENAME key newkey title: RENAME --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Renames `key` to `newkey`. It returns an error when `key` does not exist. If `newkey` already exists it is overwritten, when this happens `RENAME` executes an implicit [`DEL`]({{< relref "/commands/del" >}}) operation, so if the deleted key contains a very big value it may cause high latency even if `RENAME` itself is usually a constant-time operation. diff --git a/content/commands/renamenx.md b/content/commands/renamenx.md index be1729c427..323934b3a7 100644 --- a/content/commands/renamenx.md +++ b/content/commands/renamenx.md @@ -67,6 +67,11 @@ summary: Renames a key only when the target key name doesn't exist. syntax_fmt: RENAMENX key newkey title: RENAMENX --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Renames `key` to `newkey` if `newkey` does not yet exist. It returns an error when `key` does not exist. diff --git a/content/commands/rpoplpush.md b/content/commands/rpoplpush.md index 9a89accab5..80ab398cd6 100644 --- a/content/commands/rpoplpush.md +++ b/content/commands/rpoplpush.md @@ -69,6 +69,11 @@ summary: Returns the last element of a list after removing and pushing it to ano syntax_fmt: RPOPLPUSH source destination title: RPOPLPUSH --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Atomically returns and removes the last element (tail) of the list stored at `source`, and pushes the element at the first element (head) of the list stored at `destination`. diff --git a/content/commands/scan.md b/content/commands/scan.md index 2db649049e..51594958eb 100644 --- a/content/commands/scan.md +++ b/content/commands/scan.md @@ -56,6 +56,11 @@ summary: Iterates over the key names in the database. syntax_fmt: "SCAN cursor [MATCH\_pattern] [COUNT\_count] [TYPE\_type]" title: SCAN --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + The `SCAN` command and the closely related commands [`SSCAN`]({{< relref "/commands/sscan" >}}), [`HSCAN`]({{< relref "/commands/hscan" >}}) and [`ZSCAN`]({{< relref "/commands/zscan" >}}) are used in order to incrementally iterate over a collection of elements. * `SCAN` iterates the set of keys in the currently selected Redis database. diff --git a/content/commands/sdiff.md b/content/commands/sdiff.md index eb168c6076..6806931ba7 100644 --- a/content/commands/sdiff.md +++ b/content/commands/sdiff.md @@ -48,6 +48,11 @@ summary: Returns the difference of multiple sets. syntax_fmt: SDIFF key [key ...] title: SDIFF --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Returns the members of the set resulting from the difference between the first set and all the successive sets. diff --git a/content/commands/sdiffstore.md b/content/commands/sdiffstore.md index cb1fac5c42..0b33cbe635 100644 --- a/content/commands/sdiffstore.md +++ b/content/commands/sdiffstore.md @@ -63,6 +63,11 @@ summary: Stores the difference of multiple sets in a key. syntax_fmt: SDIFFSTORE destination key [key ...] title: SDIFFSTORE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + This command is equal to [`SDIFF`]({{< relref "/commands/sdiff" >}}), but instead of returning the resulting set, it is stored in `destination`. diff --git a/content/commands/sinter.md b/content/commands/sinter.md index e5a5664a45..b8736bf3a9 100644 --- a/content/commands/sinter.md +++ b/content/commands/sinter.md @@ -49,6 +49,11 @@ summary: Returns the intersect of multiple sets. syntax_fmt: SINTER key [key ...] title: SINTER --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Returns the members of the set resulting from the intersection of all the given sets. diff --git a/content/commands/sintercard.md b/content/commands/sintercard.md index 00c05df813..61525455de 100644 --- a/content/commands/sintercard.md +++ b/content/commands/sintercard.md @@ -56,6 +56,11 @@ summary: Returns the number of members of the intersect of multiple sets. syntax_fmt: "SINTERCARD numkeys key [key ...] [LIMIT\_limit]" title: SINTERCARD --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + This command is similar to [`SINTER`]({{< relref "/commands/sinter" >}}), but instead of returning the result set, it returns just the cardinality of the result. Returns the cardinality of the set which would result from the intersection of all the given sets. diff --git a/content/commands/sinterstore.md b/content/commands/sinterstore.md index 32df8696b5..9cb93bd7ce 100644 --- a/content/commands/sinterstore.md +++ b/content/commands/sinterstore.md @@ -64,6 +64,11 @@ summary: Stores the intersect of multiple sets in a key. syntax_fmt: SINTERSTORE destination key [key ...] title: SINTERSTORE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + This command is equal to [`SINTER`]({{< relref "/commands/sinter" >}}), but instead of returning the resulting set, it is stored in `destination`. diff --git a/content/commands/smove.md b/content/commands/smove.md index de7a2f9ef0..3fac2be76e 100644 --- a/content/commands/smove.md +++ b/content/commands/smove.md @@ -66,6 +66,11 @@ summary: Moves a member from one set to another. syntax_fmt: SMOVE source destination member title: SMOVE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Move `member` from the set at `source` to the set at `destination`. This operation is atomic. In every given moment the element will appear to be a member of `source` **or** diff --git a/content/commands/sunion.md b/content/commands/sunion.md index 961f2faed8..f85c711025 100644 --- a/content/commands/sunion.md +++ b/content/commands/sunion.md @@ -48,6 +48,11 @@ summary: Returns the union of multiple sets. syntax_fmt: SUNION key [key ...] title: SUNION --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Returns the members of the set resulting from the union of all the given sets. For example: diff --git a/content/commands/sunionstore.md b/content/commands/sunionstore.md index cc9d804f90..b2b6db2ff4 100644 --- a/content/commands/sunionstore.md +++ b/content/commands/sunionstore.md @@ -63,6 +63,11 @@ summary: Stores the union of multiple sets in a key. syntax_fmt: SUNIONSTORE destination key [key ...] title: SUNIONSTORE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + This command is equal to [`SUNION`]({{< relref "/commands/sunion" >}}), but instead of returning the resulting set, it is stored in `destination`. diff --git a/content/commands/tdigest.merge.md b/content/commands/tdigest.merge.md index c60fea4640..77fcb65611 100644 --- a/content/commands/tdigest.merge.md +++ b/content/commands/tdigest.merge.md @@ -49,6 +49,11 @@ syntax_fmt: "TDIGEST.MERGE destination-key numkeys source-key [source-key ...]\n \ [COMPRESSION compression] [OVERRIDE]" title: TDIGEST.MERGE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Merges multiple t-digest sketches into a single sketch. ## Required arguments diff --git a/content/commands/touch.md b/content/commands/touch.md index 2a063d6999..32162c8a88 100644 --- a/content/commands/touch.md +++ b/content/commands/touch.md @@ -51,6 +51,11 @@ summary: Returns the number of existing keys out of those specified after updati syntax_fmt: TOUCH key [key ...] title: TOUCH --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Alters the last access time of a key(s). A key is ignored if it does not exist. diff --git a/content/commands/ts.createrule.md b/content/commands/ts.createrule.md index c996416ac5..185962f93d 100644 --- a/content/commands/ts.createrule.md +++ b/content/commands/ts.createrule.md @@ -85,6 +85,11 @@ syntax_fmt: "TS.CREATERULE sourceKey destKey AGGREGATION\_}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Create a compaction rule diff --git a/content/commands/ts.deleterule.md b/content/commands/ts.deleterule.md index dd66a66082..75753ed3f1 100644 --- a/content/commands/ts.deleterule.md +++ b/content/commands/ts.deleterule.md @@ -31,6 +31,11 @@ summary: Delete a compaction rule syntax_fmt: TS.DELETERULE sourceKey destKey title: TS.DELETERULE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Delete a compaction rule diff --git a/content/commands/ts.madd.md b/content/commands/ts.madd.md index f8a7cce69c..88a7340dc1 100644 --- a/content/commands/ts.madd.md +++ b/content/commands/ts.madd.md @@ -38,6 +38,11 @@ summary: Append new samples to one or more time series syntax_fmt: TS.MADD key timestamp value [key timestamp value ...] title: TS.MADD --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Append new samples to one or more time series diff --git a/content/commands/ts.mget.md b/content/commands/ts.mget.md index c2ac0412ab..5405689d54 100644 --- a/content/commands/ts.mget.md +++ b/content/commands/ts.mget.md @@ -69,6 +69,11 @@ syntax_fmt: "TS.MGET [LATEST] [WITHLABELS | SELECTED_LABELS label1 [label1 ...]] \ | l= | l!= | l=(v1,v2,...) | l!=(v1,v2,...) ...]>" title: TS.MGET --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Get the sample with the highest timestamp from each time series matching a specific filter. diff --git a/content/commands/ts.mrange.md b/content/commands/ts.mrange.md index 79efec175e..ed01c64c5b 100644 --- a/content/commands/ts.mrange.md +++ b/content/commands/ts.mrange.md @@ -176,6 +176,11 @@ syntax_fmt: "TS.MRANGE fromTimestamp toTimestamp [LATEST] [FILTER_BY_TS\_Timesta \ [GROUPBY label REDUCE\n reducer]" title: TS.MRANGE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Query a range across multiple time series by filters in the forward direction. diff --git a/content/commands/ts.mrevrange.md b/content/commands/ts.mrevrange.md index 0cfe0f3068..e1d093cdc8 100644 --- a/content/commands/ts.mrevrange.md +++ b/content/commands/ts.mrevrange.md @@ -176,6 +176,11 @@ syntax_fmt: "TS.MREVRANGE fromTimestamp toTimestamp [LATEST]\n [FILTER_BY_TS\_T \ ...]> [GROUPBY label REDUCE\n reducer]" title: TS.MREVRANGE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Query a range across multiple time series by filters in the reverse direction. diff --git a/content/commands/ts.queryindex.md b/content/commands/ts.queryindex.md index 7844061295..a50d732bbe 100644 --- a/content/commands/ts.queryindex.md +++ b/content/commands/ts.queryindex.md @@ -45,6 +45,11 @@ syntax_fmt: "TS.QUERYINDEX " title: TS.QUERYINDEX --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Get all time series keys matching a filter list. Note: all matching keys will be listed, whether or not the user has read access. diff --git a/content/commands/unlink.md b/content/commands/unlink.md index 6a27747074..a280581fc3 100644 --- a/content/commands/unlink.md +++ b/content/commands/unlink.md @@ -52,6 +52,11 @@ summary: Asynchronously deletes one or more keys. syntax_fmt: UNLINK key [key ...] title: UNLINK --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + This command is very similar to [`DEL`]({{< relref "/commands/del" >}}): it removes the specified keys. Just like [`DEL`]({{< relref "/commands/del" >}}) a key is ignored if it does not exist. However the command performs the actual memory reclaiming in a different thread, so it is not diff --git a/content/commands/watch.md b/content/commands/watch.md index 1bfcded44e..45a984e097 100644 --- a/content/commands/watch.md +++ b/content/commands/watch.md @@ -48,6 +48,11 @@ summary: Monitors changes to keys to determine the execution of a transaction. syntax_fmt: WATCH key [key ...] title: WATCH --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Marks the given keys to be watched for conditional execution of a [transaction][tt]. diff --git a/content/commands/xread.md b/content/commands/xread.md index bea41fa863..5ddc83b8a3 100644 --- a/content/commands/xread.md +++ b/content/commands/xread.md @@ -70,6 +70,11 @@ syntax_fmt: "XREAD [COUNT\_count] [BLOCK\_milliseconds] STREAMS\_key [key ...] i \ [id ...]" title: XREAD --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Read data from one or multiple streams, only returning entries with an ID greater than the last received ID reported by the caller. This command has an option to block if items are not available, in a similar diff --git a/content/commands/xreadgroup.md b/content/commands/xreadgroup.md index 69f9397fe8..37e2f85c18 100644 --- a/content/commands/xreadgroup.md +++ b/content/commands/xreadgroup.md @@ -94,6 +94,11 @@ syntax_fmt: "XREADGROUP GROUP\_group consumer [COUNT\_count] [BLOCK\_millisecond \ [CLAIM\_min-idle-time] [NOACK] STREAMS\_key [key ...] id [id ...]" title: XREADGROUP --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + The `XREADGROUP` command is a special version of the [`XREAD`]({{< relref "/commands/xread" >}}) command with support for consumer groups. Probably you will have to understand the [`XREAD`]({{< relref "/commands/xread" >}}) command before reading this page will makes sense. diff --git a/content/commands/zdiff.md b/content/commands/zdiff.md index a95a678bd5..450ab31918 100644 --- a/content/commands/zdiff.md +++ b/content/commands/zdiff.md @@ -57,6 +57,11 @@ summary: Returns the difference between multiple sorted sets. syntax_fmt: ZDIFF numkeys key [key ...] [WITHSCORES] title: ZDIFF --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + This command is similar to [`ZDIFFSTORE`]({{< relref "/commands/zdiffstore" >}}), but instead of storing the resulting sorted set, it is returned to the client. diff --git a/content/commands/zdiffstore.md b/content/commands/zdiffstore.md index 6f87ab658f..02f9878fb3 100644 --- a/content/commands/zdiffstore.md +++ b/content/commands/zdiffstore.md @@ -69,6 +69,11 @@ summary: Stores the difference of multiple sorted sets in a key. syntax_fmt: ZDIFFSTORE destination numkeys key [key ...] title: ZDIFFSTORE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Computes the difference between the first and all successive input sorted sets and stores the result in `destination`. The total number of input keys is specified by `numkeys`. diff --git a/content/commands/zinter.md b/content/commands/zinter.md index 5ece420424..dc59051603 100644 --- a/content/commands/zinter.md +++ b/content/commands/zinter.md @@ -81,6 +81,11 @@ syntax_fmt: "ZINTER numkeys key [key ...] [WEIGHTS\_weight [weight ...]]\n [AGG ] [WITHSCORES]" title: ZINTER --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + This command is similar to [`ZINTERSTORE`]({{< relref "/commands/zinterstore" >}}), but instead of storing the resulting sorted set, it is returned to the client. diff --git a/content/commands/zintercard.md b/content/commands/zintercard.md index 02974b10e2..d81dd0c482 100644 --- a/content/commands/zintercard.md +++ b/content/commands/zintercard.md @@ -56,6 +56,11 @@ summary: Returns the number of members of the intersect of multiple sorted sets. syntax_fmt: "ZINTERCARD numkeys key [key ...] [LIMIT\_limit]" title: ZINTERCARD --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + This command is similar to [`ZINTER`]({{< relref "/commands/zinter" >}}), but instead of returning the result set, it returns just the cardinality of the result. Keys that do not exist are considered to be empty sets. diff --git a/content/commands/zinterstore.md b/content/commands/zinterstore.md index 79af071ff4..187cf6da34 100644 --- a/content/commands/zinterstore.md +++ b/content/commands/zinterstore.md @@ -93,6 +93,11 @@ syntax_fmt: "ZINTERSTORE destination numkeys key [key ...] [WEIGHTS\_weight\n [ \ ...]] [AGGREGATE\_]" title: ZINTERSTORE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Computes the intersection of `numkeys` sorted sets given by the specified keys, and stores the result in `destination`. It is mandatory to provide the number of input keys (`numkeys`) before passing diff --git a/content/commands/zmpop.md b/content/commands/zmpop.md index a71aafc4cf..b4225879c9 100644 --- a/content/commands/zmpop.md +++ b/content/commands/zmpop.md @@ -70,6 +70,11 @@ summary: Returns the highest- or lowest-scoring members from one or more sorted syntax_fmt: "ZMPOP numkeys key [key ...] [COUNT\_count]" title: ZMPOP --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Pops one or more elements, that are member-score pairs, from the first non-empty sorted set in the provided list of key names. `ZMPOP` and [`BZMPOP`]({{< relref "/commands/bzmpop" >}}) are similar to the following, more limited, commands: diff --git a/content/commands/zrangestore.md b/content/commands/zrangestore.md index 79d55b923e..07d7e49350 100644 --- a/content/commands/zrangestore.md +++ b/content/commands/zrangestore.md @@ -98,6 +98,11 @@ syntax_fmt: "ZRANGESTORE dst src min max [BYSCORE | BYLEX] [REV] [LIMIT\_offset\ \ count]" title: ZRANGESTORE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + This command is like [`ZRANGE`]({{< relref "/commands/zrange" >}}), but stores the result in the `` destination key. ## Examples diff --git a/content/commands/zunion.md b/content/commands/zunion.md index f907f7084e..48009e19f6 100644 --- a/content/commands/zunion.md +++ b/content/commands/zunion.md @@ -80,6 +80,11 @@ syntax_fmt: "ZUNION numkeys key [key ...] [WEIGHTS\_weight [weight ...]]\n [AGG ] [WITHSCORES]" title: ZUNION --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + This command is similar to [`ZUNIONSTORE`]({{< relref "/commands/zunionstore" >}}), but instead of storing the resulting sorted set, it is returned to the client. diff --git a/content/commands/zunionstore.md b/content/commands/zunionstore.md index 1b4eaf1446..3ed408c287 100644 --- a/content/commands/zunionstore.md +++ b/content/commands/zunionstore.md @@ -92,6 +92,11 @@ syntax_fmt: "ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS\_weight\n [ \ ...]] [AGGREGATE\_]" title: ZUNIONSTORE --- +{{< note >}} +This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. +{{< /note >}} + + Computes the union of `numkeys` sorted sets given by the specified keys, and stores the result in `destination`. It is mandatory to provide the number of input keys (`numkeys`) before passing diff --git a/content/develop/using-commands/multi-key-operations.md b/content/develop/using-commands/multi-key-operations.md new file mode 100644 index 0000000000..afaa70d8ed --- /dev/null +++ b/content/develop/using-commands/multi-key-operations.md @@ -0,0 +1,140 @@ +--- +categories: +- docs +- develop +- stack +- oss +- rs +- rc +- oss +- kubernetes +- clients +description: Multi-key command behavior across Redis configurations and clustering setups +linkTitle: Multi-key operations +title: Multi-key operations +weight: 35 +--- + +Multi-key operations in Redis allow you to work with multiple keys in a single command, but their behavior varies significantly depending on your Redis configuration and clustering setup. This page provides a quick reference for developers working with multi-key operations across different Redis configurations. + +## Configurations + +Redis supports five distinct configurations, each with different multi-key command behaviors: + +1. **ROS/RS clustering disabled** - Single Redis instance +2. **ROS, clustering enabled** - Redis Open Source cluster +3. **RS, clustering enabled, OSS cluster API enabled** - Redis Software with ROS cluster compatibility +4. **RS, clustering enabled, OSS cluster API disabled** - Redis Software proprietary clustering +5. **RS, Active-Active** - Redis Software Active-Active (considered clustered even with a single shard) + +ROS stands for Redis Open Source and RS stands for Redis Software. + +## Command behaviors + +For each configuration, commands exhibit one of three behaviors: + +- **single-slot**: Commands must operate on keys within the same hash slot +- **cross-slot (all shards)**: Commands can operate across all shards in the cluster +- **cross-slot (within a single shard)**: Commands can operate across slots but only within a single shard + +## Read-only commands + +| Behavior | Commands | +|----------|----------| +| **ROS/RS clustering disabled:**
– the whole DB (single shard)

**ROS clustering enabled, RS clustering enabled (OSS cluster API enabled):**
– the current shard

**RS clustering enabled (OSS cluster API disabled):**
– all shards | DBSIZE, KEYS, SCAN | +| **ROS/RS clustering disabled:**
– cross-slot

**ROS clustering enabled, RS clustering enabled (OSS cluster API enabled):**
– single-slot

**RS clustering enabled (OSS cluster API disabled):**
– cross-slot (all shards) | EXISTS, MGET | +| **ROS/RS clustering disabled:**
– cross-slot

**ROS clustering enabled, RS clustering enabled (OSS cluster API enabled), RS clustering enabled (OSS cluster API disabled):**
– single-slot | PFCOUNT, SDIFF, SINTER, SINTERCARD, SUNION, WATCH, XREAD, XREADGROUP, ZDIFF, ZINTER, ZINTERCARD, ZUNION | +| **ROS/RS clustering disabled:**
– cross-slot

**ROS clustering enabled, RS clustering enabled (OSS cluster API enabled), RS clustering enabled (OSS cluster API disabled):**
– single-shard | JSON.MGET

Users won't get a CROSSSLOT error. However, when clustering is enabled, and not all specified keys are in the same slot, users will get partial results for all the slots on the current shard. | +| **ROS/RS clustering disabled:**
– cross-slot (all shards)

**ROS clustering enabled, RS clustering enabled (OSS cluster API enabled), RS clustering enabled (OSS cluster API disabled):**
– cross-slot (all shards), cannot be part of a transaction | TS.MGET, TS.MRANGE, TS.MREVRANGE, TS.QUERYINDEX | + +## Read-write commands + +| Behavior | Commands | +|----------|----------| +| **ROS/RS clustering disabled:**
– the whole DB (single shard)

**ROS clustering enabled, RS clustering enabled (OSS cluster API enabled):**
– the current shard

**RS clustering enabled (OSS cluster API disabled):**
– all shards | FLUSHALL, FLUSHDB | +| **ROS/RS clustering disabled:**
– cross-slot

**ROS clustering enabled, RS clustering enabled (OSS cluster API enabled):**
– single-slot

**RS clustering enabled (OSS cluster API disabled):**
– cross-slot (all shards) | DEL, MSET, TOUCH, UNLINK

Note: on Active-Active, DEL, MSET, and UNLINK are single-slot | +| **ROS/RS clustering disabled:**
– cross-slot

**ROS clustering enabled, RS clustering enabled (OSS cluster API enabled), RS clustering enabled (OSS cluster API disabled):**
– single-slot | BITOP, BLMOVE, BLMPOP, BLPOP, BRPOP, BRPOPLPUSH, BZMPOP, BZPOPMAX, BZPOPMIN, CMS.MERGE, COPY, GEORADIUS or GEORADIUSBYMEMBER (with STORE or STOREDIST), GEOSEARCHSTORE, JSON.MSET, LMOVE, LMPOP, MSETNX, PFMERGE, RENAME, RENAMENX, RPOPLPUSH, SDIFFSTORE, SINTERSTORE, SMOVE, SUNIONSTORE, TDIGEST.MERGE, TS.MADD, ZDIFFSTORE, ZINTERSTORE, ZMPOP, ZRANGESTORE, ZUNIONSTORE | +| **ROS/RS clustering disabled:**
– cross-slot

**ROS clustering enabled, RS clustering enabled (OSS cluster API enabled), RS clustering enabled (OSS cluster API disabled):**
– single-shard | TS.CREATERULE, TS.DELETERULE

Users won't get a CROSSSLOT error. However, when clustering is enabled and the two specified keys are not in the same slot, users will get `(error) ERR TSDB: the key does not exist`. | + +## Pipelines, transactions, and scripts + +| Behavior | Operations | +|----------|------------| +| **ROS/RS clustering disabled:**
– cross-slot
**ROS clustering enabled, RS clustering enabled (OSS cluster API enabled):**
– single-slot
**RS clustering enabled (OSS cluster API disabled):**
– cross-slot (all shards) | Pipelines | +| **ROS/RS clustering disabled:**
– cross-slot
**ROS clustering enabled, RS clustering enabled (OSS cluster API enabled), RS clustering enabled (OSS cluster API disabled):**
– single-slot | Keys in a `MULTI/EXEC` transaction
Keys in a Lua script executed using EVAL or EVALSHA | + +## Examples by Configuration + +### Single Instance (No Clustering) + +In a single Redis instance, all multi-key operations work without restrictions: + +```redis +# Pipeline operations work across any keys +PIPELINE +SET user:1 "Alice" +SET product:100 "Widget" +GET user:1 +GET product:100 +EXEC + +# Transactions work with any keys +MULTI +SET counter:a 1 +SET counter:b 2 +INCR counter:a +INCR counter:b +EXEC +``` + +### Clustered Environments + +In clustered setups, you need to consider slot distribution: + +```redis +# This may fail if keys are in different slots +MSET user:1 "Alice" user:2 "Bob" + +# Use hash tags to ensure same slot +MSET {users}:1 "Alice" {users}:2 "Bob" + +# Check which slot a key belongs to +CLUSTER KEYSLOT user:1 +CLUSTER KEYSLOT {users}:1 +``` + +### Active-Active Databases + +Active-Active databases have additional restrictions for write operations: + +```redis +# Read operations can work across slots +MGET user:1 user:2 product:100 + +# Write operations must be in same slot +MSET {data}:user:1 "Alice" {data}:user:2 "Bob" +``` + +## Troubleshooting Multi-Key Operations + +### Common Error Messages + +- **CROSSSLOT**: Keys in request don't hash to the same slot +- **MOVED**: Key has moved to a different node (during resharding) +- **TRYAGAIN**: Operation temporarily unavailable (during migration) + +### Solutions + +1. **Use hash tags** to group related keys +2. **Redesign data model** to minimize cross-slot operations +3. **Check cluster state** during errors +4. **Implement retry logic** for temporary failures + +## Performance Considerations + +- **Single-slot operations** are fastest as they don't require coordination +- **Cross-slot operations** may have higher latency due to internal routing +- **Pattern commands** (KEYS, FLUSHALL) scan all shards and can be expensive +- **Module operations** may have optimized cross-slot implementations + +Choose your Redis configuration and design your data model based on your multi-key operation requirements.