COMMAND-GETKEYS(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

πŸ’… COMMAND-GETKEYS πŸ’…

okay bestie, so this one is COMMAND-GETKEYS β€” and yes, it lives in section 3valkey of the manual, we love a lil numbering moment. it's a Valkey Command Manual page and it's genuinely so useful, let me tell you everything 🫢


✨ NAME ✨

command-getkeys β€” Extracts the key names from an arbitrary command.

like... it looks at a whole command and goes "here are the keys, bestie" πŸ”‘


🌸 SYNOPSIS 🌸

COMMAND GETKEYS command arg [arg...]

πŸ¦‹ DESCRIPTION πŸ¦‹

Returns @array-reply of keys from a full Valkey command.

COMMAND GETKEYS is a helper command to let you find the keys from a full Valkey command. it's giving personal assistant energy honestly ✨

COMMAND provides information on how to find the key names of each command (see firstkey, valkey-key-specs(7) key specifications, 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 valkey-command-getkeysandflags(7) COMMAND GETKEYSANDFLAGS to discover key names directly from how Valkey parses the commands.

lowkey the whole point: when the metadata just can't tell you where the keys are, you let Valkey's own parser do the detective work. no cap πŸ’…

πŸ’– REPLY πŸ’–

valkey-protocol(7) Array reply: a list of keys from the given command.


⭐ COMPLEXITY ⭐

O(N) where N is the number of arguments to the command


πŸ‘‘ ACL CATEGORIES πŸ‘‘

@connection @slow


🌈 HISTORY 🌈

  • Available since: 2.8.13

πŸŽ€ EXAMPLES πŸŽ€

127.0.0.1:6379> COMMAND GETKEYS MSET a b c d e f
1) "a"
2) "c"
3) "e"
127.0.0.1:6379> COMMAND GETKEYS EVAL "not consulted" 3 key1 key2 key3 arg1 arg2 arg3 argN
1) "key1"
2) "key2"
3) "key3"
127.0.0.1:6379> COMMAND GETKEYS SORT mylist ALPHA STORE outlist
1) "mylist"
2) "outlist"

okay look at the first one β€” MSET a b c d e f and it hands you back a, c, e because those are the actual keys, the values are just vibing in between 🧚 the EVAL one is iconic because the script body says "not consulted" and truly it was not consulted, the 3 tells it how many keys follow. and SORT pulls out both mylist AND outlist because STORE makes an output key too. main character behavior fr fr πŸ”₯


πŸ’œ SEE ALSO πŸ’œ


that's the whole page bestie, you ate it πŸ’…βœ¨

signing off with the receipts: this is version 9.0.0, dated 2025-10-21, page COMMAND-GETKEYS(3valkey). periodt πŸŽ€

πŸ“¦ where this page comes from