hiredis redisCommand eval syntax

575 views
Skip to first unread message

Chris Love

unread,
Jun 1, 2012, 6:27:08 PM6/1/12
to redi...@googlegroups.com
Hi all

I am using the hiredis client and attempting to run a eval.

Running the following:

<code>
reply = redisCommand(c, "eval \"return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}\" 2 key1 key2 first second");
printf("EVAL: %s\n", reply->str);
freeReplyObject(reply);
</code>

Gives me:

EVAL: ERR value is not an integer or out of range

I have seen this before when you mess up the second argument that you pass into the eval command.  This eval command is right off of the website.

Thanks

Chris

Chris Love

unread,
Jun 1, 2012, 6:52:03 PM6/1/12
to redi...@googlegroups.com
I figured it out with the help of a friend.

    reply = redisCommand(c, "eval %s 1 %s", "return {KEYS[1]}", "key1");
    if (reply->type == REDIS_REPLY_ARRAY) {
           for (j = 0; j < reply->elements; j++) {
               printf("%u) %s\n", j, reply->element[j]->str);
           }
    }
    printf("EVAL: %s\n", reply->str);
    freeReplyObject(reply);

Reply all
Reply to author
Forward
0 new messages