Questions tagged [hiredis]

Hiredis is a minimalistic C client library for the Redis database

Hiredis is a minimalistic C client library for the Redis database.

It is minimalistic because it just adds minimal support for the protocol, but at the same time it uses an high level printf-alike API in order to make it much higher level than otherwise suggested by its minimal code base and the lack of explicit bindings for every Redis command.

Apart from supporting sending commands and receiving replies, it comes with a reply parser that is decoupled from the I/O layer. It is a stream parser designed for easy reusability, which can for instance be used in higher level language bindings for efficient reply parsing.

Hiredis only supports the binary-safe Redis protocol, so you can use it with any Redis version >= 1.2.0.

The library comes with multiple APIs. There is the synchronous API, the asynchronous API and the reply parsing API.

Source Code: https://github.com/redis/hiredis

139 questions
3
votes
2 answers

Why do hiredis functions use void* instead of redisReply*?

I am new to hiredis and use v0.13. I noticed that the API functions from hiredis.h, which deal with redisReply* objects, all use void*. For example, void *redisCommand(redisContext *c, const char *format, ...); returns a redisReply* object (or…
edavid
  • 371
  • 1
  • 3
  • 5
3
votes
1 answer

Writing a safe wrapper class for memory management of a user-defined object's pointer

I'm using redis c++ client to develop client APIs which will do CRUD operations on the redis cluster. The client library that I'm using returns a pointer of a redisReply structure whenever a command is executed. Later, I'm expected to use the…
Vishal Sharma
  • 1,670
  • 20
  • 55
3
votes
3 answers

Error while loading shared libraries, cannot open shared object file: No such file or directory (hiredis)

I'm in the alpha stages of writing a C program which uses redis on the back end. I've tried building/installing hiredis (make && sudo make install) and running the test (which pass mostly) but when trying to build the example.c program i get an…
T. Thomas
  • 660
  • 3
  • 10
  • 25
3
votes
2 answers

Hiredis waiting for message

I am using hiredis C library to connect to redis server. I am not able to figure out how to wait for new messages after subscribing to new message. My code look like: signal(SIGPIPE, SIG_IGN ); struct event_base *base = event_base_new(); …
Vivek Goel
  • 22,942
  • 29
  • 114
  • 186
3
votes
1 answer

Can not join ev loop thread since it is hanging in epoll_wait()

I'm using async hiredis with libev. mLoopThread is used here for ev loop thread, basically mLoopThread is calling ev_loop(). when main thread tries to destruct async hiredis instance, it calls ev_unloop to try to make ev_loop() exit. The code looks…
JustDance
  • 61
  • 1
  • 5
2
votes
1 answer

hiredis redisCommand returns null for everything on Raspberry Pi 4

I have Raspberry pi 4B with latest raspbian and updated software. I installed hiredis library from github source using their installation instructions. When I try to run following code on normal computer, everything works fine but on Raspberry Pi 4B…
Matej
  • 782
  • 2
  • 6
  • 19
2
votes
1 answer

Unable to get HiRedis TLS example-ssl to connect

I'm trying to use the HiRedis API to perform a TLS connection to a Redis server fronted by a device that can perform TLS termination. My project has a need to send customer data over the internet to a Redis server hosted in the Cloud. I need to…
Jenner
  • 329
  • 3
  • 12
2
votes
1 answer

Gracefully unsubscribe from redis at exit

I have a ruby program which listens to a redis channel: module Listener class << self def listen redis.subscribe "messaging" do |on| on.message do |_, msg| Notify.about(msg) end end end def redis …
Hirurg103
  • 4,783
  • 2
  • 34
  • 50
2
votes
1 answer

storing C struct as binary with SET in redis (hiredis)

I'm trying to save a binary blob of my structure as value in Redis (via hiredis) using SET. I set it with one execution of my program and try to retrieve it later in another run. For some reason, I'm not able to get the dynamically allocated string…
Akshay
  • 21
  • 1
  • 3
2
votes
2 answers

How to publish asynchronously with HiRedis

I am using HiRedis with a c/c++ program and have written some tests to verify that subscriptions work (I based my solution on this comment). However, currently I can only publish by manually typing something like publish foo "abcd" into the…
quant
  • 21,507
  • 32
  • 115
  • 211
2
votes
1 answer

How to stop hiredis command?

I am using hiredis library in my project. I'm using async API. I schedule a read command and wait for data. That works fine. However problem occurs when I try to close the connection - I call redisAsyncDisconnect, however the callback routine isn't…
yaqwsx
  • 569
  • 1
  • 5
  • 14
2
votes
1 answer

Issue installing hiredis on AWS Linux using OpsWorks

I'm using OpsWorks to deploy my custom node.js application. I'm not a Chef expert and thought this would be an easy process however I keep hitting snags. This most recent issue is really setting me back. Basically I'm using a package called "Kue"…
ddibiase
  • 1,412
  • 1
  • 20
  • 44
2
votes
1 answer

Can we set C int array as a key's value in Redis by hiredis?

given : int x[3] = {11,22,33}; how can save it as a key's value as binary data and get it the hiredis give example to how to set binary safestring /* Set a key using binary safe API */ reply = redisCommand(c,"SET %b %b", "bar", (size_t) 3,…
Diana Cherry
  • 45
  • 1
  • 4
2
votes
1 answer

Timeout for redisGetReply

Can I have timeout for redisGetReply? My current code is while(redisGetReply(context,&reply) == REDIS_OK) { //Check for isstopped if yes return // consume message freeReplyObject(reply); } Currently if I…
Vivek Goel
  • 22,942
  • 29
  • 114
  • 186
2
votes
1 answer

A redis command ERR:wrong number of arguments

using hiredis to pass the command to redis-server. My code: redisContext* c = redisConnect("127.0.0.1", 6379); char y[15]={"pointx"}; strcat(y," 2"); redisReply* reply= (redisReply*)redisCommand(c,"set %s",y); printf("%s\n", reply->str); The…
user2297642
  • 21
  • 1
  • 2
1
2
3
9 10