• 展开微博窗口
  • QQ:52619941
  • 微信:cnmemory
  • 展开分类目录
  • 还没有账号?

Memory

验证hiredis是否安装成功

#include <stdio.h>
#include <hiredis/hiredis.h>
int main()
{
     redisContext *conn  = redisConnect("127.0.0.1",6379);
     if(conn != NULL && conn->err)
     {
         printf("connection error: %s\n",conn->errstr);
         return 0;
     }
     redisReply *reply = (redisReply*)redisCommand(conn,"set foo 1234");
     freeReplyObject(reply);

     reply = redisCommand(conn,"get foo");
     printf("%s\n",reply->str);
     freeReplyObject(reply);

     redisFree(conn);
     return 0;
}
sudo gcc -o  RedisTest RedisTest.c -L/usr/local/lib/ -lhiredis
码字很辛苦,转载请注明来自雨林寒舍《验证hiredis是否安装成功》

评论