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

qq_花開花謝_0
TA貢獻1835條經驗 獲得超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可以連接設置了密碼的redis服務器,但是不是在連接時指定,而是在連接成功后,通過發送`AUTH`命令來指定密碼。如上述代碼所示。
- 1 回答
- 0 關注
- 1411 瀏覽
添加回答
舉報
0/150
提交
取消