Getting started with Redis configuration and C ++ in Ubuntu

Source: Internet
Author: User
Tags redis cluster install redis

Getting started with Redis configuration and C ++ in Ubuntu

Redis is a high-performance key-value database. The emergence of Redisedis largely compensates for the shortage of key/value storage such as memcached. In some cases, it can complement relational databases. It provides clients such as Java, C/C ++, C #, PHP, JavaScript, Perl, Object-C, Python, Ruby, and Erlang for ease of use.

This article introduces the configuration of Redis in Ubuntu and how to get started with C ++ to help readers get started with Redis quickly.

Install configurations

Obtain, decompress, enter the source code directory, and compile

$ Wget http://download.redis.io/releases/redis-2.8.13.tar.gz
$ Tar xzf redis-2.8.13.tar.gz
$ Redis-2.8.13 cd
$ Make

Testing and Installation

$ Make-test
$ Sudo make install

After the make command is executed, an executable file is generated under the src directory, including redis-server, redis-cli, redis-benchmark, and redis-stat. Their functions are as follows:
 
Redis-server: daemon Startup Program of the Redis server
Redis-cli: Redis command line operation tool. Of course, you can also use telnet to operate based on its plain text protocol.
Redis-benchmark: Redis performance testing tool to test the read/write performance of Redis in your system and your configuration
Redis-stat: Redis status detection tool that can detect the current status parameters and latency of Redis.

Run Redis:

$ Src/redis-server

You can interact with Redis using the built-in client:

$ Src/redis-cli
Redis> set foo bar
OK
Redis> get foo
"Bar"

C ++ configuration and getting started

Configuration

On Ubuntu:

$ Apt-get install libhiredis-dev

On OSX run:

$ Brew install hiredis

On other platforms:

$ Git clone https://github.com/antirez/hiredis.git & cd hiredis & make & sudo make install & sudo ldc

Otherwise, an error may occur due to the lack of hiredis dependency:

Error: hiredis/hiredis. h: No such file or directory

Getting started

RedisTest. cpp

# Include <stdio. h>
# Include

Int main ()
{
RedisContext * conn = redisConnect ("Wagner. 0.0.1", 6379 );
If (conn-> err ){
Printf ("connection error: % s \ n", conn-> errstr );
}

& Nbsp; redisReply * reply = (redisReply *) redisCommand (conn, "set foo 1234 ");
FreeReplyObject (reply );

& Nbsp; reply = (redisReply *) redisCommand (conn, "get foo ");
Printf ("% s \ n", reply-> str );
FreeReplyObject (reply );

& Nbsp; redisFree (conn );
Return 0;
}

Compile command

G ++ redisTest. cpp-o redisTest-I./deps/hiredis/-L./deps/hiredis/-lhiredis

Install and test Redis in Ubuntu 14.04

Redis cluster details

Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis

Redis series-installation, deployment, and maintenance

Install Redis in CentOS 6.3

Learning notes on Redis installation and deployment

Redis. conf

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.