Always NULL as reply->str #1278
Replies: 2 comments 1 reply
-
Try a simpler program first that doesn't have any other moving parts. #include <hiredis/hiredis.h>
#include <stdio.h>
#include <assert.h>
#define REDIS_HOST "127.0.0.1"
#define REDIS_PORT 6379
int main(void) {
redisContext *c;
redisReply *r;
c = redisConnect(REDIS_HOST, REDIS_PORT);
assert(c != NULL && c->err == 0);
char *redis_key = "show_id:62fda075-4c03-4b88-9894-8ba7498051b1,proceed";
r = redisCommand(c, "SET %s %s", "A", redis_key);
assert(r != NULL && r->type == REDIS_REPLY_STATUS);
printf("reply->str %s\n", r->str ? r->str : "(null)");
freeReplyObject(r);
r = redisCommand(c, "GET %s", "A");
assert(r != NULL && r->type == REDIS_REPLY_STRING);
printf("reply->str %s\n", r->str ? r->str : "(null)");
freeReplyObject(r);
redisFree(c);
}
Since you're getting non-null You can also try monitoring the Redis instance when you run your program to see if you see the commands executing. Another possibility is an ABI mismatch. This can happen if the hiredis headers are of a different version than the compiled shared object. It would cause weird random errors. |
Beta Was this translation helpful? Give feedback.
-
Found it ... Thank you, @michael-grunder I use Ruby C and I use the hiredis gem, which comes with with the hiredis c suite. So thanks for this hint!
How to solve this problem In the Ruby C module adapted the extconf.rb (sorry just hard coded for now)
hires_path can be determined via ... |
Beta Was this translation helpful? Give feedback.
-
Hey guys,
I hope that I am not stupid...
I try to access redis via hiredis.
I can actually write to redis, and get the value via redis-cli.
However trying to read reply->str ALWAYS return NULL, even on the successful SET
Same when I try to do PING, SET, SELECT, GET etc. Always NULL.
What do I do wrong?
I've installed hiredis 1.2.0 with homebrew on OSX Sonoma 14.6.1 on M2
I also compiled 1.2.1 from github.
Thanks a lot, Martin
Beta Was this translation helpful? Give feedback.
All reactions