From ee795e452d3053d4abbc3872c7a114fab9754264 Mon Sep 17 00:00:00 2001 From: Chen Tianjie Date: Fri, 1 Mar 2024 15:54:31 +0800 Subject: [PATCH] Allow by/get of sort(ro) in cluster mode. (#2611) --- commands/sort.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/commands/sort.md b/commands/sort.md index ca06ed5bd6..b6340d81e8 100644 --- a/commands/sort.md +++ b/commands/sort.md @@ -105,8 +105,11 @@ SORT mylist BY weight_* GET object_* GET # ## Restrictions for using external keys -When enabling `Redis cluster-mode` there is no way to guarantee the existence of the external keys on the node which the command is processed on. -In this case, any use of `GET` or `BY` which reference external key pattern will cause the command to fail with an error. +Before 8.0, when enabling `Redis cluster-mode` there is no way to guarantee the existence of the external keys on the node which the command is processed on. In this case, any use of `GET` or `BY` which reference external key pattern will cause the command to fail with an error. + +Starting from 8.0, pattern with hash tag can be mapped to a slot, and so in `Redis cluster-mode`, the use of `BY` or `GET` is allowed when pattern contains hash tag and implies a specific slot which the key is also in, which means any key matching this pattern must be in the same slot as the key, and therefore in the same node. For example, in cluster mode, `{mylist}weight_*` is acceptable as a pattern when sorting `mylist`, while pattern `{abc}weight_*` will be denied, causing the command to fail with an error. + +To use pattern with hash tag, see https://redis.io/docs/reference/cluster-spec/#hash-tags for more information. Starting from Redis 7.0, any use of `GET` or `BY` which reference external key pattern will only be allowed in case the current user running the command has full key read permissions. Full key read permissions can be set for the user by, for example, specifying `'%R~*'` or `'~*` with the relevant command access rules.