diff --git a/commands/keys.md b/commands/keys.md index 766299da3..f51e0ea51 100644 --- a/commands/keys.md +++ b/commands/keys.md @@ -26,6 +26,13 @@ Supported glob-style patterns: Use `\` to escape special characters if you want to match them verbatim. +When using [Redis Cluster](/docs/management/scaling/), the search is optimized for patterns that imply a single slot. +If a pattern can only match keys of one slot, +Redis only iterates over keys in that slot, rather than the whole database, +when searching for keys matching the pattern. +For example, with the pattern `{a}h*llo`, Redis would only try to match it with the keys in slot 15495, which hash tag `{a}` implies. +To use pattern with hash tag, see [Hash tags](/docs/reference/cluster-spec/#hash-tags) in the Cluster specification for more information. + @examples ```cli diff --git a/commands/scan.md b/commands/scan.md index 367830455..7ef81e47e 100644 --- a/commands/scan.md +++ b/commands/scan.md @@ -148,6 +148,12 @@ redis 127.0.0.1:6379> As you can see most of the calls returned zero elements, but the last call where a `COUNT` of 1000 was used in order to force the command to do more scanning for that iteration. +When using [Redis Cluster](/docs/management/scaling/), the search is optimized for patterns that imply a single slot. +If a pattern can only match keys of one slot, +Redis only iterates over keys in that slot, rather than the whole database, +when searching for keys matching the pattern. +For example, with the pattern `{a}h*llo`, Redis would only try to match it with the keys in slot 15495, which hash tag `{a}` implies. +To use pattern with hash tag, see [Hash tags](/docs/reference/cluster-spec/#hash-tags) in the Cluster specification for more information. ## The TYPE option