COMMAND GETKEYS
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.
Return value
Section titled “Return value”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.
Examples
Section titled “Examples”127.0.0.1:6379> COMMAND GETKEYS MSET a 1 b 21) "a"2) "b"127.0.0.1:6379> COMMAND GETKEYS SORT mylist BY weight_* STORE sorted1) "mylist"2) "sorted"127.0.0.1:6379> COMMAND GETKEYS EVAL "return 1" 2 k1 k2 arg1) "k1"2) "k2"127.0.0.1:6379> COMMAND GETKEYS PING(error) ERR The command has no key argumentsCompatibility
Section titled “Compatibility”Same replies and error strings as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.