--- acl_categories: - '@slow' - '@connection' arguments: - display_text: command name: command type: string - display_text: arg multiple: true name: arg optional: true type: string arity: -3 categories: - docs - develop - stack - oss - rs - rc - oss - kubernetes - clients command_flags: - loading - stale complexity: O(N) where N is the number of arguments to the command description: Extracts the key names from an arbitrary command. group: server hidden: false linkTitle: COMMAND GETKEYS railroad_diagram: /images/railroad/command-getkeys.svg since: 2.8.13 summary: Extracts the key names from an arbitrary command. syntax_fmt: COMMAND GETKEYS command [arg [arg ...]] title: COMMAND GETKEYS --- Returns [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of keys from a full Redis command. `COMMAND GETKEYS` is a helper command to let you find the keys from a full Redis command. [`COMMAND`]({{< relref "/commands/command" >}}) provides information on how to find the key names of each command (see `firstkey`, [key specifications]({{< relref "develop/reference/key-specs#logical-operation-flags" >}}), and `movablekeys`), but in some cases it's not possible to find keys of certain commands and then the entire command must be parsed to discover some / all key names. You can use `COMMAND GETKEYS` or [`COMMAND GETKEYSANDFLAGS`]({{< relref "/commands/command-getkeysandflags" >}}) to discover key names directly from how Redis parses the commands. ## Examples {{% redis-cli %}} COMMAND GETKEYS MSET a b c d e f COMMAND GETKEYS EVAL "not consulted" 3 key1 key2 key3 arg1 arg2 arg3 argN COMMAND GETKEYS SORT mylist ALPHA STORE outlist {{% /redis-cli %}} ## Redis Software and Redis Cloud compatibility | Redis
Software | Redis
Cloud | Notes | |:----------------------|:-----------------|:------| | ✅ Standard
✅ Active-Active | ✅ Standard
✅ Active-Active | | ## Return information {{< multitabs id="command-getkeys-return-info" tab1="RESP2" tab2="RESP3" >}} [Array reply](../../develop/reference/protocol-spec#arrays): list of keys from the given command. -tab-sep- [Array reply](../../develop/reference/protocol-spec#arrays): a list of keys from the given command. {{< /multitabs >}}