Skip to content

Commit

Permalink
Update KEYS and SCAN page about pattern with hash tag (#2610)
Browse files Browse the repository at this point in the history
The optimization done in redis/redis#12754.
  • Loading branch information
CharlesChen888 authored Mar 7, 2024
1 parent 66da565 commit a1e94d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions commands/keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions commands/scan.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a1e94d9

Please sign in to comment.