Skip to content

Instantly share code, notes, and snippets.

@steinnes
Created March 7, 2015 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steinnes/820fbe2b7032935e9450 to your computer and use it in GitHub Desktop.
Save steinnes/820fbe2b7032935e9450 to your computer and use it in GitHub Desktop.
hiredis test
#include <stdio.h>
#include <hiredis/hiredis.h>
int redis_set(char *key, char *value) {
redisContext *c = redisConnect("127.0.0.1", 6379);
if (c != NULL && c->err) {
printf("Error connecting to redis: %s\n", c->errstr);
return -1;
}
redisCommand(c, "SET %s %s", key, value);
}
int main(void)
{
redis_set("test_key", "test_value");
}
apt-get install libhiredis-dev
gcc r.c -o r -lhiredis
./r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment