I'm using the hiredis C client library to interact with Redis in an async context.
On some point of my workflow I have to make a Sync call to Redis but I'm not being able to get a successful response from Redis.
I'm not sure whether I can issue a sync command to Redis from an async context but...
I have something like this
redisAsyncContext * redis_ctx;
redisReply * reply;
// ...
reply = redisCommand(&(redis_ctx->c), COMMAND);
After redisCommand
call, my reply
is NULL what is documented as an error condition and my redis_ctx->c
is like
err = 0
errstr = '\000' <repeats 127 times>
fd = 11
flags = 2
obuf = "*5\r\n$4\r\nEVAL\r\n$215\r\n\"math.randomseed(tonumber(ARGV[1])) local keys = redis.call('hkeys',KEYS[1]) if #keys == 0 then return nil end local key = keys[math.random(#keys)] local value = redis.call('hget', KEYS[1], key) return {key, value}\"\r\n$1\r\n1\r\n$0\r\n\r\n$1\r\n1\r\n"
reader = 0x943730
I can't figure out whether the command was issued or not.
Hope it's not too late. I'm not so expert about Redis, but if you need to make a Sync call to Redis, why would you use an AsyncContext?
If you just use redisCommand with a redisContext everything should be fine.
Assuming that variable
ctx
has been declared asyou can use
redisCommand
like this: