Redis CLIENT SETNAME

Redis Server 教育
Redis Server Course
Redis 定期点検/技術支援
Redis Technical Support
Redis エンタープライズサーバ
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 返事がかかってなれば、メールでお知らせします。

패턴으로 값을 조회하고 삭제할 수 있어요.
리스트에서 "lls mylist user*" 이렇게 조회할 수 있구요.
user가 들어간 값들을 삭제하려면 "lrm mylist user*" 이렇게 하면 됩니다.
List에서는 LLS, LRM, Set에서는 SLS, SRM, ZSet에서는 ZLS, ZRM, Hash에서는 HLS, HRM 을 사용하면 됩니다.
게다가 LS는 소트 기능까지 있습니다. 한번 사용해 보세요. ^^
궁금하신 사항이 있으면 여기로 redisgate@gmail.com 메일 주세요.
 
close
IP를 기반으로 보여집니다.