Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Client Getname Command

Redis Client Getname Command

Redis Server

The Redis Client Getname command is used to return CLIENT SETNAME the name set for the connection by the command. Because newly created connections have no name by default, CLIENT GETNAME returns an empty reply for unnamed connections.

Syntax

The basic syntax of the redis Client Getname command is as follows:



redis 127.0.0.1:6379> CLIENT GETNAME

Available Version

= 2.6.9

Return Value

If the connection has no name set, an empty reply is returned; if a name is set, the name is returned.

Example



# New connections default to having no name



redis 127.0.0.1:6379> CLIENT GETNAME

(nil)



# Set name



redis 127.0.0.1:6379> CLIENT SETNAME hello-world-connection

OK



# Return name



redis 127.0.0.1:6379> CLIENT GETNAME

"hello-world-connection"

Redis Server