Today, Mayuyu to learn how to operate a Redis database in C + +. Implemented through the Hiredis.h interface, currently available only in Linux environments.
The following four methods are mainly included
1. rediscontext* redisconnect (const char *IP, int port)
This function is used to connect to the Redis database, two parameters are the IP and port of the Redis database, the port number is generally 6379. Similar
also provides a function for the connection time-out limit, which is
rediscontext* redisconnectwithtimeout (const char *IP, int port, Timeval TV).
2. void *rediscommand (Rediscontext *c, const char *format ... )
This function is used to execute commands in the Redis database, the first parameter is the Rediscontext returned by the connected database, and the remaining parameters
As a prinf () function in the C language.
The return value of this function is void*, but is generally cast to the redisreply type for further processing.
3. void Freereplyobject (void *reply)
Releases the memory occupied by the Redisreply returned after Rediscommand execution.
4. void Redisfree (Rediscontext *c)Online gambling
Releases the connection generated by the Redisconnect ().
Next is to let Mayuyu to teach you how to install Hiredis it!
First download the hiredis.tar.gz package on the website, extract found inside there is a makefile file, and then perform make to compile, get
Next put the libhiredis.so into the/usr/local/lib/, put the hiredis.h into the/usr/local/inlcude/hiredis/.
Recommended Reading http://www.cnblogs.com/huangdj/p/4136633.html
C + + operations Redis database