client

UK[?kla??nt] US[?kla??nt]

n.Customer;Party;Litigation client;[Computer]Client

Plural: clients

set

UK[set] 美[s?t]

vt. Set; place, arrange; put in a certain situation ;place tableware

vi.set;set off;condensate

n.gather;a set, a pair;set;TV

adj.fixed;located... of; stubborn; arranged

Third person singular: sets Plural: sets Present participle: setting Past tense: set Past participle: set

name

英[ne?m] 美[nem]

n. Name; reputation; someone with the name of; a famous person

vt. Determine; decide; name...; say The name of…

adj. Famous; named after

Third person singular: names Plural: names Present participle: naming Past tense: named Past participle: named

redis CLIENT SETNAME command syntax

Function: Assign a name to the current connection.

Syntax: CLIENT SETNAME connection-name

Description: This name will be displayed in the result of the CLIENT LIST command and is used to identify the current The client that connects to the server. When a connection leak occurs in a Redis application, setting a name for the connection is a good debugging method.

Available versions: >= 2.6.9

Time complexity: O(1)

Return: Return OK when setting is successful.

redis CLIENT SETNAME command example

# 新連接默認(rèn)沒有名字
redis 127.0.0.1:6379> CLIENT GETNAME
(nil)
# 設(shè)置名字
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 ""     # 必須雙引號(hào)顯示包圍
OK
redis 127.0.0.1:6379> CLIENT GETNAME        # 清除完畢
(nil)