Expand description
Where a command’s keys are, and what it does to each of them.
§Why the old triple was not enough
Until now the answer was three numbers on every table row: the first
argument that is a key, the last, and how far apart they sit. That triple is
Redis’s own legacy answer, it is what COMMAND INFO has reported since 2.8,
and it is wrong often enough to matter. ZUNIONSTORE dst 2 a b has three
keys and the triple names one of them. XREAD COUNT 2 STREAMS a b 0 0 has
two and the triple names none. SORT k STORE d has two and the triple names
one.
Nothing minded very much while the only caller was COMMAND GETKEYS, where
a wrong answer is a cluster client routing to the wrong node and a real but
distant problem. The ACL is a different matter. A user given ~cache:* and
nothing else must not be able to reach secret through ZUNIONSTORE, and a
permission check built on a key finder that misses keys is not a permission
check. So this is the model Redis replaced the triple with in 7.0, copied
rather than approximated, and the triple stays beside it because
COMMAND INFO still reports it.
§The model
A command has a list of key specs and each one is two questions. Where does
this run of keys start, which is Begin, and how far does it go, which is
Find. ZUNIONSTORE has two: one key at argument one, and a counted run
starting at argument two. SMOVE has two, one for each end of the move,
which is how the source can be a delete and the destination an insert.
Beside them are the flags, and those are the half the ACL reads. RO, RW,
OW and RM say how the value is touched, and access, update, insert
and delete say what a caller has to be allowed to do: a key with access
needs read permission and a key with any of the other three needs write
permission. That is why SET k v needs only write while INCR k needs both,
which is not a rule anybody would guess and is not derivable from the command
flags. It comes off the reference one command at a time.
§What incomplete means
Three specs cannot be trusted on their own and say so. SORT’s BY, GET
and STORE keys are Begin::Unknown, because the first two are patterns
that name keys only after the sorted value has been read and the third can
appear anywhere. XREAD and XREADGROUP look for the word STREAMS, which
a stream could be called. MIGRATE and the two GEORADIUS writes look for a
keyword that may appear twice.
A spec carrying incomplete, or one whose search is unknown, means the
answer this module gives is a floor rather than the whole of it. COMMAND GETKEYS fills the rest in per command, and the ACL treats a command with one
as needing permission over every key, which is the safe way round: a user
who may reach every key is allowed and one who may not is refused.
Structs§
- Access
- What a caller has to be allowed to do with a key.
- KeySpec
- One run of keys in a command’s arguments.
- Run
- One run of keys, resolved against the arguments a client actually sent.
Enums§
Constants§
- BITFIELD_
KEY - This command allows both access and modification of the key
- BYMEMBER_
STORE - Incomplete because duplicate STORE options use last-wins; fall back to georadiusGetKeys
- BYMEMBER_
STOREDIST - Incomplete because duplicate STOREDIST options use last-wins; fall back to georadiusGetKeys
- DELEX_
KEY - RW, delete, variable_flags.
- GEORADIUS_
STORE - Incomplete because duplicate STORE options use last-wins; fall back to georadiusGetKeys
- GEORADIUS_
STOREDIST - Incomplete because duplicate STOREDIST options use last-wins; fall back to georadiusGetKeys
- MIGRATE_
KEYS - RW, access, delete, incomplete.
- NOT_
KEY_ AT1 - not_key.
- NOT_
KEY_ AT1_ RM1_ 1_ 0 - not_key.
- OW_
INSERT_ AT1 - OW, insert.
- OW_
INSERT_ AT2 - OW, insert.
- OW_
INSERT_ AT1_ RM1_ 2_ 0 - OW, insert.
- OW_
UPDATE_ AT1 - OW, update.
- OW_
UPDATE_ AT2 - OW, update.
- OW_
UPDATE_ AT1_ COUNTED - OW, update.
- OW_
UPDATE_ AT1_ RM1_ 2_ 0 - OW, update.
- RM_
DELETE_ AT1_ RM1_ 1_ 0 - RM, delete.
- RO_
ACCESS_ AT1 - RO, access.
- RO_
ACCESS_ AT2 - RO, access.
- RO_
ACCESS_ AT1_ COUNTED - RO, access.
- RO_
ACCESS_ AT1_ R1_ 1_ 0 - RO, access.
- RO_
ACCESS_ AT1_ RM1_ 1_ 0 - RO, access.
- RO_
ACCESS_ AT1_ RM2_ 1_ 0 - RO, access.
- RO_
ACCESS_ AT2_ COUNTED - RO, access.
- RO_
ACCESS_ AT2_ RM1_ 1_ 0 - RO, access.
- RO_
ACCESS_ AT3_ RM1_ 1_ 0 - RO, access.
- RO_AT1
- RO.
- RO_AT2
- RO.
- RO_
AT1_ RM1_ 1_ 0 - RO.
- RW_
ACCESS_ AT2 - RW, access.
- RW_
ACCESS_ AT1_ RM1_ 1_ 0 - RW because it may change the internal representation of the key, and propagate to replicas
- RW_
ACCESS_ DELETE_ AT1 - RW, access, delete.
- RW_
ACCESS_ DELETE_ AT3 - RW, access, delete.
- RW_
ACCESS_ DELETE_ AT1_ COUNTED - RW, access, delete.
- RW_
ACCESS_ DELETE_ AT1_ RM2_ 1_ 0 - RW, access, delete.
- RW_
ACCESS_ DELETE_ AT2_ COUNTED - RW, access, delete.
- RW_
ACCESS_ INSERT_ AT1 - RW, access, insert.
- RW_
ACCESS_ UPDATE_ AT1 - RW, access, update.
- RW_
ACCESS_ UPDATE_ AT2 - RW, access, update.
- RW_
ACCESS_ UPDATE_ AT1_ R1_ 1_ 0 - RW, access, update.
- RW_
ACCESS_ UPDATE_ AT1_ RM1_ 3_ 0 - RW, access, update.
- RW_
ACCESS_ UPDATE_ AT1_ TTL - RW and UPDATE because it changes the TTL
- RW_
ACCESS_ UPDATE_ AT2_ COUNTED - RW, access, update.
- RW_
DELETE_ AT1 - RW, delete.
- RW_
DELETE_ AT2 - RW, delete.
- RW_
INSERT_ AT1 - RW, insert.
- RW_
INSERT_ AT2 - RW, insert.
- RW_
UPDATE_ AT1 - RW, update.
- RW_
UPDATE_ AT2 - RW, update.
- RW_
UPDATE_ AT1_ TRIMMING - UPDATE instead of INSERT because of the optional trimming feature
- RW_
UPDATE_ DELETE_ AT1 - RW, update, delete.
- SCRIPT_
KEYS_ RO - We cannot tell how the keys will be used so we assume the worst, RO and ACCESS
- SCRIPT_
KEYS_ RW - We cannot tell how the keys will be used so we assume the worst, RW and UPDATE
- SET_KEY
- RW and ACCESS due to the optional
GETargument - SORT_
BY_ AND_ GET - For the optional BY/GET keyword. It is marked ‘unknown’ because the key names derive from the content of the key we sort
- SORT_
STORE - For the optional STORE keyword. It is marked ‘unknown’ because the keyword can appear anywhere in the argument array
- XREADGROUP_
STREAMS - Incomplete because a consumer/group named STREAMS (or options before GROUP) can shift the STREAMS keyword; fall back to xreadGetKeys
- XREAD_
STREAMS - Incomplete because a stream key named STREAMS (or options before it) can shift the STREAMS keyword; fall back to xreadGetKeys
Functions§
- access_
of - What a caller needs over a key carrying
flags. - find
- Every key
specnames inargs, handed toeacha run at a time. - of_sub
- The key specs for
container sub, empty for a subcommand that has none. - takes_
keys - Whether this command ever names a key, whatever it is sent.