【问题标题】:A redis command ERR:wrong number of arguments hiredisredis命令错误:hiredis的参数数量错误
【发布时间】:2020-12-28 02:00:26
【问题描述】:

当我通过hiredis 适配器执行“脚本加载”命令时,我收到错误错误no of argument。通过 Redis 客户端的相同命令运行良好。

reply_r= (redisReply *)redisCommand(con_r,"script","load", "return 1");
      string stemp="";
      if(reply_r->len>0)
        {
          string stt(reply_r->str);
          stemp=stt;
          //printf("Commad Reply : %s\n", reply_r->str);
    
        }
      freeReplyObject(reply_r);//  should free the object after reading the data
      return stemp;

【问题讨论】:

    标签: c++ c redis lua


    【解决方案1】:
    reply_r= (redisReply *)redisCommand(con_r,"scrips load %s", "return 1");
          string stemp="";
          if(reply_r->len>0 && reply_r!=NULL)
            {
              
              stemp=string(reply_r->str);          
        
            }
          freeReplyObject(reply_r);//  should free the object after reading the data
          return stemp;
    

    【讨论】:

    • 最好检查返回的reply_r 是否为nullptr。题外话:也可以试试redis-plus-plus,内置支持SCRIPTS LOAD命令:auto sha = redis.script_load("return 1");
    猜你喜欢
    • 1970-01-01
    • 2017-09-22
    • 2021-08-09
    • 1970-01-01
    • 2014-03-05
    • 1970-01-01
    • 2015-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多