MGET(3valkey)

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

✨ MGET β€” the manual page, but make it make sense ✨

okay so bestie, welcome to the Valkey Command Manual πŸ’… this one's called MGET and it's lowkey one of the most iconic little commands in the whole repo. let's get into it 🫢


🌸 NAME 🌸

mget β€” atomically returns the string values of one or more keys.

like. it goes and grabs your stuff. all at once. atomically. no cap πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

MGET key [key...]

that's it. that's the whole vibe. one key, or a whole lil squad of keys, your call ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

Returns the values of all specified keys. 🫢

For every key that does not hold a string value or does not exist, the special value nil is returned. so if a key is missing or it's holding something that isn't a string, you don't get an error, you just get nil in that slot. it's giving "no thoughts, head empty, but polite about it" πŸ’€

and because of that whole nil situation, the operation never fails. literally never. it cannot fail. main character energy fr fr πŸ‘‘


πŸ’– REPLY πŸ’–

valkey-protocol(7) Array reply: a list of values at the specified keys.

so you get an array back, one entry per key you asked about, in the exact order you asked. periodt. ✨


⭐ COMPLEXITY ⭐

O(N) where N is the number of keys to retrieve.

so like, the more keys you throw at it, the more work it does. obviously. it's proportional, bestie, that's the whole thing 🌈


πŸ”₯ ACL CATEGORIES πŸ”₯

  • @fast
  • @read
  • @string

three little badges, all slaying πŸ’…


πŸ‘‘ HISTORY πŸ‘‘

  • Available since: 1.0.0

she's been here since the beginning. an OG. a legend. we stan πŸŽ€


🌸 EXAMPLES 🌸

okay so here's the classic lil demo, look how cute this is:

127.0.0.1:6379> SET key1 "Hello"
OK
127.0.0.1:6379> SET key2 "World"
OK
127.0.0.1:6379> MGET key1 key2 nonexisting
1) "Hello"
2) "World"
3) (nil)

see how nonexisting just quietly returns (nil) instead of making a whole scene? that's the energy. no drama, no error, just vibes πŸ’œ


🧚 SEE ALSO 🧚

go read these next, bestie, they're all in the same friend group:


okay that's the whole page, you ate that πŸ’… this was Valkey Command Manual version 9.0.0, dated 2025-10-21, and honestly? iconic. go MGET something, bestie, you've earned it πŸ“πŸ¦‹βœ¨

πŸ“¦ where this page comes from