Let’s talk fast, accurate AI at Google Cloud Next.

Join us in Vegas on April 22-24.

Hiredis

Make Hiredis super easy with Redis Enterprise

Using Redis with C

In order to use Redis with C you will need a C Redis client. In following sections, we will demonstrate the use of hiredis, a minimalistic C client for Redis. Additional C clients for Redis can be found under the C section of the Redis Clients page.

Installing hiredis

Download the latest hiredis release from the GitHub repository.

Opening a Connection to Redis Using hiredis

The following code creates a connection to Redis using hiredis’ synchronous API:

To adapt this example to your code, make sure that you replace the following values with those of your database:

  • In line 1, the first argument to 'redisConnect' should be your database’s hostname or IP address
  • In line 1, the second argument to 'redisConnect' should be your database’s port
  • In line 6, replace “password” with your database’s password

Using SSL and hiredis

hiredis does not support SSL connections natively. For an added security measure, you can secure the connection using stunnel.

Reading and Writing Data with hiredis

Once connected to Redis, you can start reading and writing data. The following code snippet writes the value

to the Redis key

, reads it back, and prints it:

The output of the above code should be:

Redis Enterprise enables running Redis datasets in a highly available and auto-scalable manner, with predictable top performance.

The Redis Enterprise Software lets you install an enterprise grade Redis cluster in your environment of choice, whether an on-premises data-center or your preferred cloud platform. It gives you full control of your data and configuration – no clustering or sharding knowledge required!

Redis Cloud is a fully-managed cloud service for hosting and running Redis dataset without dealing with nodes, clusters, failure recovery or performance stabilization. Our technology does all that in a fully automated manner. Redis Cloud is available on all popular clouds and platforms-as-a-service.

For more information on using Redis’ products and services with c please see the How to page.