1.API函数查询
http://github.com.redis/hiredis
2.直接在hiredis目录下新建 test_redis.c
2.1创建文件:
目录下有hiredis
2.2编译
添加环境变量
2.3运行
./a.out 直接运行
redis-cli get itcast 客户端运行
2.4 文件编写
int mainset()
{
redisContext *pr=redisConnect("127.0.0.1",6379); //1.连接
if(pr!=NULL)
{
redisReply *reply=redisCommand(pr,"set it%s ","abc"); //2.发命令 命令行里发送的
freeReplyObject(reply); //3.销毁object
reply=redisCommand(pr,"get itcase");
puts(reply->str);
freeReplyObject(reply);
}
}
int mainget()
{
redisContext *pr=redisConnect("127.0.0.1",6379); //1.连接
if(pr!=NULL)
{
redisReply *reply=redisCommand(pr,"set it%s ","abc");//2.发命令 命令行里发送的
freeReplyObject(reply); //3.销毁object
reply=redisCommand(pr,"get itcase");
puts(reply->str);
}
}