Redis Installation steps:
1.redis Server Installation wget http://redis.googlecode.com/files/redis-2.4.6.tar.gz #下载文件
Tar xzf redis-2.4.6.tar.gz
CD redis-2.4.6
Make
CP Src/redis-server src/redis-cli/usr/bin/#方便在终端在任何地方直接运行
CP redis.conf/etc/
UFW Allow 6379 #ubuntu下开启端口
Modify the/etc/redis.conf to have the server perform the daemon in the background.
Daemonize Yes
2. Start Redis Service
Redis-server/etc/redis.conf
3. Detect whether the Redis service starts normally
Ps-ef | grep Redis
Hiredis Client Download Address: Https://github.com/redis/hiredis
Hiredis installation steps:
Tar zxvf Antirez-hiredis-v0.10.1-0-g3cc6a7f.zip
CD antirez-hiredis-3cc6a7f
make
Mkdir/usr/lib/hiredis
CP Libhiredis.so/usr/lib/hiredis #将动态连接库libhiredis. So to/usr/lib/hiredis
Mkdir/usr/include/hiredis
CP Hiredis.h/usr/include/hiredis
1. Connect hiredis server
#include <stdio.h>
#include < Hiredis/hiredis.h>
Rediscontext *conn = Redisconnect ("127.0.0.1", 6379);//redis Server default port
if ( Conn->err) {
printf ("Connection error:%s", conn->str);
}
2. Send command to server
redisreply *reply = Rediscommand (conn, "set key value");
3. Close the Reply object
Freereplyobject (reply);
4. Close the connection
Redisfree (conn);
Specific Some other APIs can look at the file's readme.md