CLIENT-SETNAME(3valkey)

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

✨ CLIENT-SETNAME ✨

okay bestie, welcome to the valkey command manual, CLIENT-SETNAME edition πŸ’– this one's short, sweet, and lowkey iconic.

🌸 NAME 🌸

client-setname β€” gives your connection a little name tag πŸŽ€

πŸ¦‹ SYNOPSIS πŸ¦‹

CLIENT SETNAME connection-name

πŸ’œ DESCRIPTION πŸ’œ

So basically, CLIENT SETNAME slaps a name onto the current connection. That's it. That's the whole job. πŸ‘‘

And why do we care? Because that name you just gave it shows up in the output of valkey-client-list(7) CLIENT LIST β€” so now you can actually tell which client did a thing on a given connection. no more mystery connections, we love to see it πŸ”₯

fr fr, picture this: you're using Valkey to implement a queue, and your producers and consumers both want to announce their whole role in life by naming their connection accordingly. now they can. main character energy for every connection πŸ’…

Now for the deets:

  • There's no limit to how long the name can be β€” beyond the usual limits of the String type, that's 512 MB. go off, write a novel, we support you πŸ“š
  • BUT you can't use spaces in a connection name, because that would violate the format of the CLIENT LIST reply. sorry babe, no spaces. 😭
  • You can completely remove the connection name by setting it to the empty string β€” and fun fact, the empty string is not a valid connection name, precisely because it serves this one specific purpose. it's the "no name" name 🫢
  • Wanna peek at what the name currently is? Use valkey-client-getname(7) CLIENT GETNAME. πŸ‘€
  • Every brand-new connection starts out with no assigned name. fresh start, no baggage ✨
πŸ’‘ Tip: naming your connections is a genuinely great way to debug connection leaks caused by bugs in the application using Valkey. yes bestie, name them and catch the leaky ones πŸ”

🌈 REPLY 🌈

valkey-protocol(7) Simple string reply: OK if the connection name was successfully set. πŸŽ‰

⭐ COMPLEXITY ⭐

O(1) β€” constant time, instant, no thoughts required, we love efficiency πŸ’«

πŸŽ€ ACL CATEGORIES πŸŽ€

@connection @slow

πŸ¦„ HISTORY πŸ¦„

  • Available since: 2.6.9

πŸ‘‘ SEE ALSO πŸ‘‘


and that's a wrap, bestie 🫢 this page is from Valkey 9.0.0, dated 2025-10-21. go name those connections, you absolute legend πŸ’–βœ¨

πŸ“¦ where this page comes from