好吧,我在centos6中使用hiredis客户端连接redis服务器并使用它的redisAppendCommand()向服务器发送命令。
redisContext *redisConnect(ip,port);
std::string value = "E 1";
std::string field_name = "field";
std::string id_code = "id";
std::string key = "HSET type:info:"+ id_code + " " + field_name + " " +value;
redisAppendCommand(_contxt, key.c_str());
它无法按照我的意愿将值设置为E 1 。然后我像这样更改代码,
redisContext *redisConnect(ip,port);
std::string value = "E 1";
std::string field_name = "field";
std::string id_code = "id";
std::string key = "HSET type:info:"+ id_code + " " + field_name + " \"" +value + "\"";
redisAppendCommand(_contxt, key.c_str());
但是值将包含 \" 作为它的内容,所以值变为\"E 1\",我只是想知道是否有任何方法可以使用hiredis 设置E 1的值?谢谢。