Credis 是一个纯C 的Redis 客户端开发包,示例代码:
#include <stdio.h> #include "credis.h" int main(int argc, char **argv) { REDIS rh; char *val; /* create handle to a Redis server running on localhost, port 6789, with a 2 second response timeout */ rh = credis_connect(NULL, 6789, 2000); /* ping server */ credis_ping(rh); /* set value of key "kalle" to "kula" */ credis_set(rh, "kalle", "kula"); /* get value of key "kalle" */ credis_get(rh, "kalle", &val); printf("get kalle returned: %s\n", val); /* close connection to redis server */ credis_close(rh); return 0; }