-
-
Save steinnes/820fbe2b7032935e9450 to your computer and use it in GitHub Desktop.
hiredis test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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