C + + operations Redis database

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.