Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Documentation for CLIENT GETNAME and SETNAME.

  • Loading branch information...
commit 730ebd87ba9710deb9e0ab782266edcde0155745 1 parent b8b557f
@antirez authored
View
18 commands.json
@@ -151,6 +151,24 @@
"since": "2.4.0",
"group": "server"
},
+ "CLIENT GETNAME": {
+ "summary": "Get the current connection name",
+ "complexity": "O(1)",
+ "since": "2.6.9",
+ "group": "server"
+ },
+ "CLIENT SETNAME": {
+ "summary": "Set the current connection name",
+ "complexity": "O(1)",
+ "since": "2.6.9",
+ "arguments": [
+ {
+ "name": "connection-name",
+ "type": "string"
+ }
+ ],
+ "group": "server"
+ },
"CONFIG GET": {
"summary": "Get the value of a configuration parameter",
"arguments": [
View
5 commands/client getname.md
@@ -0,0 +1,5 @@
+The `CLIENT GETNAME` returns the name of the current connection as set by `CLIENT SETNAME`. Since every new connection starts without an associated name, if no name was assigned a null bulk reply is returned.
+
+@return
+
+@bulk-reply: The connection name, or a null bulk reply if no name is set.
View
19 commands/client setname.md
@@ -0,0 +1,19 @@
+The `CLIENT SETNAME` command assigns a name to the current connection.
+
+The assigned name is displayed in the output of `CLIENT LIST` so that it is possible to identify the client that performed a given connection.
+
+For instance when Redis is used in order to implement a queue, producers and consumers of messages may want to set the name of the connection according to their role.
+
+There is no limit to the length of the name that can be assigned if not the usual limits of the Redis string type (512 MB). However it is not possible to use spaces in the connection name as this would violate the format of the `CLIENT LIST` reply.
+
+It is possible to entirely remove the connection name setting it to the empty string, that is not a valid connection name since it serves to this specific purpose.
+
+The connection name can be inspected using `CLIENT GETNAME`.
+
+Every new connection starts without an assigned name.
+
+Tip: setting names to connections is a good way to debug connection leaks due to bugs in the application using Redis.
+
+@return
+
+@status-reply: `OK` if the connection name was successfully set.
Please sign in to comment.
Something went wrong with that request. Please try again.