client_setname
Redis CLIENT SETNAME
|  Redis Server Course |  Redis Technical Support |  Redis Enterprise Server | 
|---|
Redis CLIENT SETNAME
현재 연결된 클라이언트 자신의 이름을 설정한다. 다른 클라이언트의 이름을 설정할 수 없다.
이름 중간에 Space, New Line 같은 특수 문자를 포함할 수 없다. 
ASCII Code 10진수로 33과 126사이의 문자만 사용할 수 있다.   
출력 가능한 문자가 32부터인데, 32번이 '공백'이라서 제외되었다.   
이유는 client list명령에 텍스트로 name이 표시되어야 하기 때문이다.
Example
| 명령> | client setname RedisGate | 
| 결과> | OK | 
| 명령> | client getname | 
| 결과> | "RedisGate" | 
| 명령> | client setname !@#$%^&*()_+ | 
| 결과> | OK | 
| 명령> | client getname | 
| 결과> | "!@#$%^&*()_+" | 
| 명령> | client setname "Redis Gate" | 
| 결과> | (error) ERR Client names cannot contain spaces, newlines or special characters. | 
Source code
Version 3.0.2관련된 부분만 표시했다.
networking.c 
void clientCommand(redisClient *c) {
    if (!strcasecmp(c->argv[1]->ptr,"setname") && c->argc == 3) {
        int j, len = sdslen(c->argv[2]->ptr);
        char *p = c->argv[2]->ptr;
        /* Setting the client name to an empty string actually removes
         * the current name. */
        if (len == 0) {
            if (c->name) decrRefCount(c->name);
            c->name = NULL;
            addReply(c,shared.ok);
            return;
        }
        /* Otherwise check if the charset is ok. We need to do this otherwise
         * CLIENT LIST format will break. You should always be able to
         * split by space to get the different fields. */
        for (j = 0; j < len; j++) {
            if (p[j] < '!' || p[j] > '~') { /* ASCII is assumed. */
                addReplyError(c,
                    "Client names cannot contain spaces, "
                    "newlines or special characters.");
                return;
            }
        }
        if (c->name) decrRefCount(c->name);
        c->name = c->argv[2];
        incrRefCount(c->name);
        addReply(c,shared.ok);
    }
}
		
명령문
CLIENT SETNAME parameter
- 이 명령은 version 2.6.9 부터 사용할 수 있다.
| Clients for C | Hiredis | 
| << CLIENT GETNAME | CLIENT SETNAME | CLIENT LIST >> | 
|---|
조회수 :
	Email
	
	
	답글이 올라오면 이메일로 알려드리겠습니다.
	
 


 
  
			 
			