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 will introduce the Redis configuration in the Ubuntu environment,
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
# Include
Int main ()
{
RedisContext * conn = redisConnect ("Wagner. 0.0.1", 6379 );
If (conn-> err ){
Printf ("connection error: % s \ n", conn-> errstr );
}
RedisReply * reply = (redisReply *) redisCommand (conn, "set foo 1234 ");
FreeReplyObject (reply );
Reply = (redisReply *) redisCommand (conn, "get foo ");
Printf ("% s \ n", reply-> str );
FreeReplyObject (reply );
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.04Http://www.linuxidc.com/Linux/2014-05/101544.htm
Redis cluster details document http://www.linuxidc.com/Linux/2013-09/90118.htm
Ubuntu 12.10 install Redis (graphic details) + Jedis connection Redis http://www.linuxidc.com/Linux/2013-06/85816.htm
Redis series-installation, deployment, maintenance http://www.linuxidc.com/Linux/2012-12/75627.htm
CentOS 6.3 install Redis http://www.linuxidc.com/Linux/2012-12/75314.htm
Redis installation deployment learning notes http://www.linuxidc.com/Linux/2014-07/104306.htm
Redis configuration file redis. conf detailed description http://www.linuxidc.com/Linux/2013-11/92524.htm
For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2
This article permanently updates the link address: Http://www.linuxidc.com/Linux/2014-07/104651.htm