C++中訪問redis,用hiredis接口可以指定密碼嗎
1 回答

qq_花開花謝_0
TA貢獻(xiàn)1835條經(jīng)驗 獲得超7個贊
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | redisContext *c = redisConnect("hostname", port);if (c != NULL && c->err) { printf("Error: %s\n", c->errstr); // handle error } else { printf("Connected to Redis\n"); }
redisReply *reply; reply = redisCommand(c, "AUTH password"); freeReplyObject(reply);
...
redisFree(c); |
hiredis可以連接設(shè)置了密碼的redis服務(wù)器,但是不是在連接時指定,而是在連接成功后,通過發(fā)送`AUTH`命令來指定密碼。如上述代碼所示。
- 1 回答
- 0 關(guān)注
- 1407 瀏覽
添加回答
舉報
0/150
提交
取消