当前位置: 软件>C/C++软件
Redis的C客户端 credis
本文导语: Credis 是一个纯C 的 Redis 客户端开发包,示例代码: #include #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, 678...
Credis 是一个纯C 的 Redis 客户端开发包,示例代码:
#include
#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: %sn", val);
/* close connection to redis server */
credis_close(rh);
return 0;
}