Latest web development tutorials

Redis de comandos de cliente SetName

servidor Redis

Redis Cliente comando SetName se utiliza para especificar el nombre de la conexión actual.

Este nombre se mostrará en la lista de clientes de comandos consecuencia, actualmente se utiliza para identificar el servidor para conectar con el cliente.

gramática

Redis cliente SetName sintaxis del comando básico es el siguiente:

redis 127.0.0.1:6379> CLIENT SETNAME connection-name

versiones disponibles

> = 2.6.9

Valor de retorno

Atrás Aceptar la hora de establecer el éxito.

Ejemplos

# 新连接默认没有名字

redis 127.0.0.1:6379> CLIENT GETNAME
(nil)

# 设置名字

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

# 返回名字

redis 127.0.0.1:6379> CLIENT GETNAME
"hello-world-connection"

# 在客户端列表中查看

redis 127.0.0.1:6379> CLIENT LIST
addr=127.0.0.1:36851
fd=5
name=hello-world-connection     # <- 名字
age=51
...

# 清除名字

redis 127.0.0.1:6379> CLIENT SETNAME        # 只用空格是不行的!
(error) ERR Syntax error, try CLIENT (LIST | KILL ip:port)

redis 127.0.0.1:6379> CLIENT SETNAME ""     # 必须双引号显示包围
OK

redis 127.0.0.1:6379> CLIENT GETNAME        # 清除完毕
(nil)

servidor Redis