Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

COMMAND GETKEYS

Last updated
COMMAND GETKEYS command [argument ...]
Group
Server
Complexity
O(N) where N is the number of arguments
Arity
-3 (at least 3 words, counting the command name)
HotKV Cloud
All plans
On-Premise
no license needed

COMMAND GETKEYS takes a complete command, with its arguments, and returns which of the arguments are keys. Nothing is run. Cluster clients use it for commands whose keys cannot be found from fixed positions, such as EVAL, SORT with STORE, or ZUNIONSTORE.

An array of the key arguments as bulk strings, in RESP2 and RESP3.

Errors:

Case Error
Unknown command ERR Invalid command specified
Wrong number of arguments for that command ERR Invalid number of arguments specified for command
The command takes no keys ERR The command has no key arguments
The arguments that locate the keys are not valid (for example a bad numkeys) ERR Invalid arguments specified for command

A script command (EVAL, FCALL and their variants) with numkeys 0 returns an empty array rather than an error.

127.0.0.1:6379> COMMAND GETKEYS MSET a 1 b 2
1) "a"
2) "b"
127.0.0.1:6379> COMMAND GETKEYS SORT mylist BY weight_* STORE sorted
1) "mylist"
2) "sorted"
127.0.0.1:6379> COMMAND GETKEYS EVAL "return 1" 2 k1 k2 arg
1) "k1"
2) "k2"
127.0.0.1:6379> COMMAND GETKEYS PING
(error) ERR The command has no key arguments

Same replies and error strings as Redis 7 and Valkey 8.

COMMAND GETKEYSANDFLAGS, COMMAND INFO, CLUSTER KEYSLOT